项目环境
tomcat7 和maven3.3.9
正确部署过程
步骤一:修改修改tomcat的conf目录下tomcat-users.xml文件,在项中添加
步骤二:修改maven的conf目录下settings.xml文件
1.在
这三个字段的值是自己定的
2.在
步骤三:配置项目的pom.xml文件,向其中增加如下字段
其中的字段
步骤四:发布
使用 mvn tomcat7:deploy 命令发布
配置成功结果
[INFO] Including org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing D:\WorkSpace\enjoyread\target\enjoyread.war with D:\WorkSpace\enjoyread\target\enjoyread-1-shaded.war
[INFO] Dependency-reduced POM written at: D:\WorkSpace\enjoyread\dependency-reduced-pom.xml
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) < package @ enjoyread <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ enjoyread ---
[INFO] Deploying war to http://localhost:8080/enjoyread
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread&update=true
Uploaded: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread&update=true (30550 KB at 18788.0 KB/sec)
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Deployed application at context path /enjoyread but context failed to start
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:02 min
[INFO] Finished at: 2017-03-30T22:21:30+08:00
[INFO] Final Memory: 20M/237M
[INFO] ------------------
[图片上传中。。。(1)]
存在问题部署(踩过的坑,分享一个存在问题的部署)
步骤一:修改修改tomcat的conf目录下tomcat-users.xml文件,在项中添加
步骤二:修改maven的conf目录下settings.xml文件,在中增加
这三个字段的值是自己定的
步骤三:配置项目的pom.xml文件,向其中增加如下字段
其中的字段
步骤四:发布
使用 mvn tomcat:deploy 命令发布
遇到错误
错误一:使用mvn tomcat:deploy出现如下错误
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.0:deploy (default-cli) on project my-webapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fdms&war=
解决方式
1.在maven的conf目录下的settings.xml文件中增加如下字段:
2.删除{Path}/.m2\repository\org\apache\tomcat\maven下的文件,然后mvn clean install
3.使用tomcat7:deploy
错误二:在发布项目时,会出现如下错误:
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread
2064/30550 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread
2054/30550 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread
2054/30550 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fenjoyread
2054/30550 KB
解决方式
使用tomcat7:redeploy代替tomcat:deploy
猜测错误原因:可能是已经发布过项目,tomcat正在占用着原来的项目,可能冲突导致