Maven远程部署项目到Tomcat7
2015-10-09 14:34
465 查看
tomcat-users.xml文件中如下配置:
1. <role rolename="manager-gui"/>
2.
<role rolename="manager-script"/>
3. <user username="suny" password="123456" roles="manager-gui, manager-script" />
Maven工程中pom.xml文件如下配置:
1. <plugin>
2. <groupId>org.codehaus.mojo</groupId>
3. <artifactId>tomcat-maven-plugin</artifactId>
4. <configuration>
5. <url>http://192.168.1.200:8080/manager/text</url>
6.
<server>test</server>
7. <path>/MyService</path>
8. </configuration>
9. </plugin>
在~/.m2/settings.xml文件中如下配置:
1. <?xml version="1.0" encoding="UTF-8"?>
2.
<settings>
3. <servers>
4.
<server>
5. <id>test</id> #对应pom.xml 中的 <server>test</server>
6.
<username>suny</username> #对应tomcat-users.xml中的用户名,密码
7. <password>123456</password>
8.
</server>
9. </servers>
10.
</settings>
eclipse中配置部署
1. mvn tomcat:deploy
2. mvn tomcat:undeploy
3. mvn tomcat:start
4. mvn tomcat:stop
5. mvn tomcat:redeploy
部署时出现的问题:
1、web.xml which will be ignored
[WARNING] Warning: selected war files include aWEB-INF/web.xml which will be ignored (webxml attribute is missing from wartask, or ignoreWebxml attribute is specified as 'true')
在使用Maven 编译项目的时候会出现
[WARNING] Warning: selected war files include aWEB-INF/web.xml which will be ignored
解决方法:
pom.xml增加
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
2、内存溢出
[ERROR] Java heap space -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Mavenwith the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debuglogging.
[ERROR]
[ERROR] For more information about the errors and possiblesolutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError 解决方法:
调整java的堆大小的值。
a、在maven中设置
1、Windows环境中
2、找到文件%M2_HOME%\bin\mvn.bat,这就是启动Maven的脚本文件,在该文件中你能看到有一行注释为:
@REM set MAVEN_OPTS=-Xdebug -Xnoagent-Djava.compiler=NONE...
它的意思是你可以设置一些Maven参数,我们就在注释下面加入一行:
setMAVEN_OPTS= -Xms128m -Xmx512m
之后,当你运行Maven命令如 mvn -version 的时候,你会看到如下的输出:
E:\test>mvn -version
E:\test>setMAVEN_OPTS= -Xms128m -Xmx512m
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "windows 2003" version: "5.2" arch:"x86" Family: "windows"
我们看到,配置的Maven选项生效了,
b、m2eclipse中
类似以上的方法都会失效,所幸m2eclipse提供了配置点。步骤如下:
项目上右击 -> Run As -> Run Configurations -> Maven Build
上右击 -> New
这时会看到一个maven运行配置对话框,这里面其它的配置我不多解释了,为了解决内存溢出的问题,我们可以选择第二个TAB: JRE,然后在VM arguments中输入配置如:-Xms128m -Xmx512m。
3、403错误
maven 403 No server username specified - using default Cannot invoke Tomcat manager: Server rened HTTP response code: 403 for URL
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy(default-cli) on project my_struts: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fframework&war=
INFO] Deploying war to http://localhost:8080/report
[DEBUG] No server username specified - using default
解决方法:
这个问题是因为你的tomcat里面没有写权限。
见步骤3中tomcat-user.xml的配置
4、 Application already exists
这是因为已经存在同名的war包。
[ERROR]
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on projectcomponentlibrary:
Cannot invoke Tomcat manager: FAIL
- Application already exists at path
/comlib ->
[Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project componentlibrary:
Cannot invoke Tomcat manager: FAIL
- Application already exists at path
/comlib
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)
解决方法:
a、更换<path>/comlib</path> 中的路径
b、增加<update>true</update>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
1. <role rolename="manager-gui"/>
2.
<role rolename="manager-script"/>
3. <user username="suny" password="123456" roles="manager-gui, manager-script" />
Maven工程中pom.xml文件如下配置:
1. <plugin>
2. <groupId>org.codehaus.mojo</groupId>
3. <artifactId>tomcat-maven-plugin</artifactId>
4. <configuration>
5. <url>http://192.168.1.200:8080/manager/text</url>
6.
<server>test</server>
7. <path>/MyService</path>
8. </configuration>
9. </plugin>
在~/.m2/settings.xml文件中如下配置:
1. <?xml version="1.0" encoding="UTF-8"?>
2.
<settings>
3. <servers>
4.
<server>
5. <id>test</id> #对应pom.xml 中的 <server>test</server>
6.
<username>suny</username> #对应tomcat-users.xml中的用户名,密码
7. <password>123456</password>
8.
</server>
9. </servers>
10.
</settings>
eclipse中配置部署
1. mvn tomcat:deploy
2. mvn tomcat:undeploy
3. mvn tomcat:start
4. mvn tomcat:stop
5. mvn tomcat:redeploy
部署时出现的问题:
1、web.xml which will be ignored
[WARNING] Warning: selected war files include aWEB-INF/web.xml which will be ignored (webxml attribute is missing from wartask, or ignoreWebxml attribute is specified as 'true')
在使用Maven 编译项目的时候会出现
[WARNING] Warning: selected war files include aWEB-INF/web.xml which will be ignored
解决方法:
pom.xml增加
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
2、内存溢出
[ERROR] Java heap space -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Mavenwith the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debuglogging.
[ERROR]
[ERROR] For more information about the errors and possiblesolutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError 解决方法:
调整java的堆大小的值。
a、在maven中设置
1、Windows环境中
2、找到文件%M2_HOME%\bin\mvn.bat,这就是启动Maven的脚本文件,在该文件中你能看到有一行注释为:
@REM set MAVEN_OPTS=-Xdebug -Xnoagent-Djava.compiler=NONE...
它的意思是你可以设置一些Maven参数,我们就在注释下面加入一行:
setMAVEN_OPTS= -Xms128m -Xmx512m
之后,当你运行Maven命令如 mvn -version 的时候,你会看到如下的输出:
E:\test>mvn -version
E:\test>setMAVEN_OPTS= -Xms128m -Xmx512m
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "windows 2003" version: "5.2" arch:"x86" Family: "windows"
我们看到,配置的Maven选项生效了,
b、m2eclipse中
类似以上的方法都会失效,所幸m2eclipse提供了配置点。步骤如下:
项目上右击 -> Run As -> Run Configurations -> Maven Build
上右击 -> New
这时会看到一个maven运行配置对话框,这里面其它的配置我不多解释了,为了解决内存溢出的问题,我们可以选择第二个TAB: JRE,然后在VM arguments中输入配置如:-Xms128m -Xmx512m。
3、403错误
maven 403 No server username specified - using default Cannot invoke Tomcat manager: Server rened HTTP response code: 403 for URL
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy(default-cli) on project my_struts: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fframework&war=
INFO] Deploying war to http://localhost:8080/report
[DEBUG] No server username specified - using default
解决方法:
这个问题是因为你的tomcat里面没有写权限。
见步骤3中tomcat-user.xml的配置
4、 Application already exists
这是因为已经存在同名的war包。
[ERROR]
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on projectcomponentlibrary:
Cannot invoke Tomcat manager: FAIL
- Application already exists at path
/comlib ->
[Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project componentlibrary:
Cannot invoke Tomcat manager: FAIL
- Application already exists at path
/comlib
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)
解决方法:
a、更换<path>/comlib</path> 中的路径
b、增加<update>true</update>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
相关文章推荐
- java-模拟tomcat服务器
- i-jetty环境搭配与编译
- 实现单Tomcat多Server配置
- 生产环境下的Tomcat配置
- Linux部署Tomcat服务器
- maven学习
- maven插件maven-war-plugin的使用
- jenkins------结合maven将svn项目自动部署到tomcat下
- jenkins------部署项目到jboss eap下
- 如何搞定tomcat这只喵~
- maven使用经验集
- tomcat在opensuse下开机自启失败的原因分析及解决方法
- jsp项目中更改tomcat的默认index.jsp访问路径的方法
- Tomcat 多端口 多应用
- tomcat 5.0 + apache 2.0 完全安装步骤详解
- Tomcat安全设置 win2003 下tomcat权限限制
- Jsp和PHP共用80端口整合Apache和Tomcat(访问时无需加端口号)
- Tomcat服务器 安全设置第1/3页
- tomcat 6.0.20在一个机器上安装多个服务的方法