亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

NetBeans + Glassfish --> NoSuchMethodError

NetBeans + Glassfish --> NoSuchMethodError

慕絲7291255 2022-06-15 15:29:59
使用 api google-cloud-translate 時會發生以下異常。我正在使用應用服務器 Glassfish 4、JSF 和 bootfaces 在 NetBeans 中開發一個 Web 應用程序。示例代碼:public void traducir (String text){Translate translate= TranslateOptions.getDefaultInstance().getService();   //Traduccion InglésTranslation translation = translate.translate(text,TranslateOption.sourceLanguage("es"), TranslateOption.targetLanguage("en")); String traduccionIngles =  translation.getTranslatedText(); System.out.println("Ingles traducido= " + traduccionIngles);}此方法引發以下運行時異常    Advertencia:   #{subirFicheroManagedBean.traducirTextosNuevos()}: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;javax.faces.FacesException: #{subirFicheroManagedBean.traducirTextosNuevos()}: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)    at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
查看完整描述

2 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

I have executed the command "mvn dependency:tree -Dverbose -Dincludes=com.google.guava"


    [INFO] Scanning for projects...

    [INFO] 

    [INFO] --------------------< com.sample:traducionMvn >---------------------

    [INFO] Building traducionMvnPOM 1.0-SNAPSHOT

    [INFO] --------------------------------[ war ]---------------------------------

    [INFO] 

    [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ traducionMvn ---

    [INFO] com.cticontrol:traducionMvn:war:1.0-SNAPSHOT

    [INFO] \- com.google.guava:guava:jar:27.0.1-jre:compile

    [INFO]    +- com.google.guava:failureaccess:jar:1.0.1:compile

    [INFO]    \- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile

    [INFO] ------------------------------------------------------------------------

    [INFO] BUILD SUCCESS

    [INFO] ------------------------------------------------------------------------

    [INFO] Total time:  1.607 s

    [INFO] Finished at: 2019-02-18T11:27:14+01:00

    [INFO] ------------------------------------------------------------------------



my pom is:

  <!-- Dependecias API TRADUCTOR GOOGLE -->

        <dependency>

            <groupId>com.google.cloud</groupId>

            <artifactId>google-cloud-translate</artifactId>

            <!-- <version>1.61.0</version> -->

            <version>1.62.0</version>


            <exclusions>

                <exclusion>

                    <groupId>com.google.guava</groupId>

                    <artifactId>guava</artifactId>

                </exclusion>

                <exclusion>

                    <artifactId>com.google</artifactId>

                    <groupId>guava</groupId>

                </exclusion>

            </exclusions>


        </dependency>


        <dependency>

            <groupId>com.google.api-client</groupId>

            <artifactId>google-api-client</artifactId>

            <version>1.28.0</version>


            <exclusions>

                <exclusion>

                    <groupId>com.google.guava</groupId>

                    <artifactId>guava</artifactId>

                </exclusion>

                <exclusion>

                    <artifactId>com.google</artifactId>

                    <groupId>guava</groupId>

                </exclusion>

            </exclusions>


        </dependency>


        <dependency>

            <groupId>com.google.guava</groupId>

            <artifactId>guava</artifactId>

            <version>27.0.1-jre</version>

        </dependency>


        <!-- Fin dependencias API -->


------------------------------------

I keep giving the same error. 


查看完整回答
反對 回復 2022-06-15
?
翻閱古今

TA貢獻1780條經驗 獲得超5個贊

發生這種情況是因為google-api-client版本依賴于 Guava 的版本。不要在 pom.xml 中使用 guava依賴項,而是嘗試更改為直接的android 變體:1.28.026.0-android27.0.1-jre-jre26.0-jre


    <dependency>

        <groupId>com.google.guava</groupId>

        <artifactId>guava</artifactId>

        <version>26.0-jre</version>

    </dependency>

有關此討論的更多信息,有一個小線程。


查看完整回答
反對 回復 2022-06-15
  • 2 回答
  • 0 關注
  • 99 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號