15

私はmvn tomcat:deployを実行しようとしていますが、エラーが発生しました

 [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project appanalytix: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project appanalytix: Cannot invoke
Tomcat manager
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
    at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:203)
    at sun.net.www.http.HttpClient.New(HttpClient.java:290)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
    at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:597)
    at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
    at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
    at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
    at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)

maven\conf\settings.xml

<server>
<id>TomcatServer</id>
<username>admin</username>
<password>admin</password>
</server>

tomcat-7.0.39\conf\tomcat-users

 <tomcat-users>
 <role rolename="manager"/>
 <role rolename="manager-gui"/>
 <role rolename="admin"/>
 <user username="admin" password="admin" roles="admin,manager,manager-gui"/>
 </tomcat-users>

pom.xml

  <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
    <mode>war</mode>
    <url>http://localhost:8080/manager</url>
    <server>TomcatServer</server>
    <path>/appanalytix</path>
  </configuration>
</plugin>

/text/html 使用してみまし たが、うまくいきません。これを解決するのを手伝ってください

4

5 に答える 5

22

次の方法は私にとってはうまくいきます。

  1. pom.xml含めるように変更してください

    <project>
        ...
        <build>    
            <plugins>    
            ....
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <url>http://localhost:8080/manager/text</url>
                        <server>my-tomcat</server>
                        <path>/myapp</path>
                    </configuration>
                </plugin>
            </plugins>
            ...
        </build>
        ...
    </project>
    
  2. Tomcat 7 サーバーに次の行があることを確認しますTOMCAT_HOME/conf/tomcat-users.xml

    <!-- Role to manage WAR files via HTML /manager. The name should be as is! -->
    <role rolename="manager-gui"/>
    <!-- Role to manage WAR files via script like Maven. The name should be as is! -->
    <role rolename="manager-script"/>
    
    <!-- One user cannot have manager-gui and manager-script roles -->
    <user username="managerGui" password="managerPwd" roles="manager-gui"/>
    <user username="manager" password="managerPwd" roles="manager-script"/>
    
  3. USER_HOME/.m2/settings.xmlパスワードを含めるように構成します。

    <settings>
        ...
        <servers>
            ...
            <server>
                <id>my-tomcat</id>
                <username>manager</username>
                <password>managerPwd</password>
            </server>
        </servers>
    
    </settings>
    
  4. を使用してデプロイmvn tomcat7:redeploy

詳細については、http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.htmlを参照してください。

于 2013-04-30T05:38:29.600 に答える
0

私の場合、解決策はうまくいきました。私は Apache Tomcat サーバーを起動しないというちょっとしたミスをしました。

これとは別に、タグ内の maven/conf/setting.xml に適切なエントリを作成するようにユーザーに指示します:-

<server>
    <id>TomcatServer</id>
    <username>admin</username>
    <password>password</password>
</server>

Apache Tomcat 7 tomcat-users.xml では、次の行を

<tomcat-users>

<role rolename="manager-gui"/>
    <role rolename="manager-script"/>
     <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <role rolename="admin-gui"/>
      <role rolename="admin-script"/>
    <user username="admin" password="password" roles="standard,manager,admin,manager-gui,manager-script,tomcat" /> 

Pom.xml 内

 <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8888/manager/text</url>
        <server>TomcatServer</server>
        <path>$ReplaceWithWarFileName$</path>
        <update>true</update>
        <username>admin</username>
        <password>password</password>
    </configuration>
</plugin>
于 2016-01-28T01:06:18.943 に答える
-1

私の場合にうまくいった解決策は次のとおりです。

  1. Main クラスを持つモジュールに移動します。
  2. このモジュールの下にある pom.xml を右クリックします。
  3. 「Maven の実行」 -> 「UpdateSnapshots」を選択します。
于 2014-08-26T08:39:49.800 に答える