码迷,mamicode.com
首页 > 其他好文 > 详细

利用maven命令把maven项目部署到tomcat服务器(部署命令,遇到的问题)

时间:2016-08-21 06:25:27      阅读:393      评论:0      收藏:0      [点我收藏+]

标签:

 

1.1maven命令(部署项目到tomcat的一些常用命令)


• mvn tomcat:run or mvn tomcat7:run

is deploy to embedded maven tomcat6 or tomcat7
do not need to start tomcat first
• mvn tomcat:deploy

need to configure that :

<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>

mvn tomcat7:deploy

need configuration:

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>

Both them need to start tomcat first,the result is the same.


• tomcat7:redeploy  重新部署
• tomcat7:undeploy 删除部署
• tomcat7:stop        
• tomcat7:start

1.2 issues about maven deploy project to tomcat(部署时候出现的一些问题)


1. [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project maven_ssh2_shopping: Cannot invoke Tomcat manager: Error writing to server -> [Help 1]
• 配置:(tomcat7:deploy和tomcat:deplop是不同的,配置不一样,下面红色区分)

如果是tomcat:deplop,则:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<!--如果是tomcat7:deploy  ,利用如下代码

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>

-->
<configuration>
<url>http://localhost:8080/manager/text</url>
<!-- server、username、password对应maven的setting下的配置 -->
<server>tomcat</server>
<username>tomcat</username>
<password>tomcat</password>
<path>/${project.build.finalName}</path>
<!-- war文件路径缺省情况下指向target -->
<!--<warFile>${basedir}/target/${project.build.finalName}.war</warFile>-->
</configuration>
</plugin>

如果是tomcat7:deploy  ,则:

<plugin>

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>

<configuration>
<url>http://localhost:8080/manager/text</url>
<!-- server、username、password对应maven的setting下的配置 -->
<server>tomcat</server>
<username>tomcat</username>
<password>tomcat</password>
<path>/${project.build.finalName}</path>
<!-- war文件路径缺省情况下指向target -->
<!--<warFile>${basedir}/target/${project.build.finalName}.war</warFile>-->
</configuration>
</plugin>

• 清空之前部署到tomcat的所有文件,保证启动tomcat没有报错

 

2.
[WARNING] The POM for my.ckfinder:CKFinder:jar:2.4.3 is missing, no dependency information available
[WARNING] The POM for my.ckfinder:CKFinderPlugin-FileEditor:jar:2.4.3 is missing, no dependency information available
[WARNING] The POM for my.ckfinder:CKFinderPlugin-ImageResize:jar:2.4.3 is missing, no dependency information available
[WARNING] The POM for my.ckfinder:CKFinderPlugin-Watermark:jar:2.4.3 is missing, no dependency information available
[WARNING] The POM for my.ckeditor:ckeditor-java-core:jar:3.5.3 is missing, no dependency information available

3. 重复部署
maven redeploy过程无法删除Tomcat旧项目的目录
必须修改$TOMCAT_HOME/conf/context.xml
context 标签上 添加 “antiJARLocking”, “antiResourceLocking” 属性,并都设置为 true,即可!
来自 <http://my.oschina.net/andy1989/blog/499655>


4. mvn Tomcat7:run出现

org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer — Eclipse Spring Project

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) on project maven_ssh2_shopping: Could not start Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: A child container failed during start -> [Help 1]
答案:


I got this error, while configuring my Spring Based Web Application in Tomcat 7(using Maven).In my pom.xml the following dependency was there:

 

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>javax.servlet-api</artifactId>

<version>3.1.0</version>

</dependency>

 


Due to which the javax.servlet jar is getting included in the deployment artifact. Upon providing the scope "provided" to the above mentioned dependency I was able to fix the issue. Hope this helps....

 

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>javax.servlet-api</artifactId>

<version>3.1.0</version>

<scope>provided</scope>

</dependency>

来自 <http://stackoverflow.com/questions/21708828/org-springframework-web-springservletcontainerinitializer-cannot-be-cast-to-java>
(思考问题为什么出现,maven依赖范围的影响,重复包的影响)

 

利用maven命令把maven项目部署到tomcat服务器(部署命令,遇到的问题)

标签:

原文地址:http://www.cnblogs.com/avaj/p/5791735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!