【发布时间】:2014-07-23 11:02:35
【问题描述】:
我正在使用 tomcat7-maven-plugin 部署我的 spring 批处理管理应用程序,
下面是我在pom中的配置,
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- Tomcat 7 has a different manager path - text - than other versions -->
<url>http://localhost:8081/manager/text</url>
<username>myusername</username>
<password>mypassword</password>
<path>/${project.build.finalName}</path>
<update>true</update>
</configuration>
</plugin>
我在跑步,
mvn clean install tomcat7:deploy
虽然成功完成,但完成此命令所需的时间太长,几乎(4-5 分钟)。
下面是命令的输出。上传war文件后需要很长时间才能收到响应。您可以在输出下方观察,耗时 4.16 分钟。
它运行得非常快,直到它显示消息“已上传..”但之后它一直等待响应 4-5 分钟。
我需要在多台服务器(5 台服务器)上部署应用程序,因此需要 25 分钟,这对于仅部署来说太长了。
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.st:batch:war:1.0.0-BUILD-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.batch:spring-batch-core:jar -> version ${spring.batch.version} vs (?) @ line 125, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.batch:spring-batch-infrastructure:jar -> version ${spring.batch.version} vs (?) @ line 129, column 15
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is missing. @ line 182, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. @ line 189, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ org.springframework.batch:spring-batch-admin-parent:1.3.0.RC1, /home/ubuntu/.m2/repository/org/springframework/batch/spring-batch-admin-parent/1.3.0.RC1/spring-batch-admin-parent-1.3.0.RC1.pom, line 245, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ org.springframework.batch:spring-batch-admin-parent:1.3.0.RC1, /home/ubuntu/.m2/repository/org/springframework/batch/spring-batch-admin-parent/1.3.0.RC1/spring-batch-admin-parent-1.3.0.RC1.pom, line 253, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building st 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ batch ---
[INFO] Deleting /home/ubuntu/java/spring/batch/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ batch ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 105 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ batch ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 53 source files to /home/ubuntu/java/spring/batch/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ batch ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ubuntu/java/spring/batch/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ batch ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ batch ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ batch ---
[INFO] Packaging webapp
[INFO] Assembling webapp [batch] in [/home/ubuntu/java/spring/batch/target/batch-1.0.0-BUILD-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ubuntu/java/spring/batch/src/main/webapp]
[INFO] Webapp assembled in [130 msecs]
[INFO] Building war: /home/ubuntu/java/spring/batch/target/batch-1.0.0-BUILD-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ batch ---
[INFO] Installing /home/ubuntu/java/spring/batch/target/batch-1.0.0-BUILD-SNAPSHOT.war to /home/ubuntu/.m2/repository/com/st/batch/1.0.0-BUILD-SNAPSHOT/batch-1.0.0-BUILD-SNAPSHOT.war
[INFO] Installing /home/ubuntu/java/spring/batch/pom.xml to /home/ubuntu/.m2/repository/com/st/batch/1.0.0-BUILD-SNAPSHOT/batch-1.0.0-BUILD-SNAPSHOT.pom
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.1:deploy (default-cli) @ batch >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ batch ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 105 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ batch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ batch ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ubuntu/java/spring/batch/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ batch ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ batch ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ batch ---
[INFO] Packaging webapp
[INFO] Assembling webapp [batch] in [/home/ubuntu/java/spring/batch/target/batch-1.0.0-BUILD-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ubuntu/java/spring/batch/src/main/webapp]
[INFO] Webapp assembled in [73 msecs]
[INFO] Building war: /home/ubuntu/java/spring/batch/target/batch-1.0.0-BUILD-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.1:deploy (default-cli) @ batch <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.1:deploy (default-cli) @ batch ---
[INFO] Deploying war to http://localhost:8081/batch-1.0.0-BUILD-SNAPSHOT
Uploading: http://localhost:8081/manager/text/deploy?path=%2Fbatch-1.0.0-BUILD-SNAPSHOT&update=true
Uploaded: http://localhost:8081/manager/text/deploy?path=%2Fbatch-1.0.0-BUILD-SNAPSHOT&update=true (16362 KB at 116869.5 KB/sec)
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] OK - Deployed application at context path /batch-1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:16 min
[INFO] Finished at: 2014-07-23T11:49:33+00:00
[INFO] Final Memory: 23M/303M
[INFO] -------------------------
【问题讨论】:
-
那是因为
tomcat7:deploy等待应用程序启动而不是Tomcat,这可能需要很长时间。 -
如果我手动启动tomcat,应用程序会在tomcat启动后立即启动。使用maven插件时发生这种情况有什么原因吗?
-
很明显,当你重新部署应用程序时,它会停止旧版本,取消部署它,然后部署新版本并启动它
-
首先我建议清理我的构建,它有很多警告。
标签: java maven tomcat7 maven-tomcat-plugin