maven 部署项目
?通过maven的tomcat插件发布项目
在第一次发布时候使用 tomcat:deploy ? 第二次后用 tomcat:redeploy
1,pom.xml的配置
?
properties下配置
<webapp.contextPath.test>/delaydoc</webapp.contextPath.test>
<webapp.port.test>80</webapp.port.test>
<tomcat.server.test>test-server-tomcat</tomcat.server.test>
<tomcat.manager.test>http://tools.winupon.tst/manager/text</tomcat.manager.test>
<tomcat.uriEncoding.test>UTF-8</tomcat.uriEncoding.test>
?
?
ps:
1.1,delaydoc 是指发布的文件夹(项目名称) 发布好后 http://tools.winupon.tst/delaydoc 就可以访问
1.2,test-server-tomcat 是.m2下settings.xml下配置的tomcat用户id
?
?<!-- Tomcat 热部署的 manager 账户 -->
? ? <servers>
? ? ? ? <server>
? ? ? ? ? ? <id>test-server-tomcat</id>
? ? ? ? ? ? <username>manager</username>
? ? ? ? ? ? <password>zdsoft</password>
? ? ? ? </server>
? ? </servers>
?
1.3,http://tools.winupon.tst/manager/text 是tomcat管理用户访问路径
?
?
2,tomcat配置插件
? ? ?<plugins>
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-compiler-plugin</artifactId>
? ? ? ? ? ? ? ? <version>2.3.2</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <source>1.6</source>
? ? ? ? ? ? ? ? ? ? <target>1.6</target>
? ? ? ? ? ? ? ? ? ? <encoding>UTF-8</encoding>
? ? ? ? ? ? ? ? ? ? <fork>true</fork>
? ? ? ? ? ? ? ? ? ? <debug>true</debug>
? ? ? ? ? ? ? ? ? ? <optimize>true</optimize>
? ? ? ? ? ? ? ? ? ? <failonerror>true</failonerror>
? ? ? ? ? ? ? ? ? ? <deprecation>true</deprecation>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
?
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-resources-plugin</artifactId>
? ? ? ? ? ? ? ? <version>2.4.3</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <encoding>UTF-8</encoding>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
?
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-war-plugin</artifactId>
? ? ? ? ? ? ? ? <version>2.1.1</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <archive>
? ? ? ? ? ? ? ? ? ? ? ? <manifest>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
? ? ? ? ? ? ? ? ? ? ? ? </manifest>
? ? ? ? ? ? ? ? ? ? ? ? <manifestEntries>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <Implementation-Qualifier>${package.qualifier}</Implementation-Qualifier>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <Implementation-Timestamp>${BUILD_ID}</Implementation-Timestamp>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <Implementation-Revision>r${SVN_REVISION}</Implementation-Revision>
? ? ? ? ? ? ? ? ? ? ? ? </manifestEntries>
? ? ? ? ? ? ? ? ? ? </archive>
? ? ? ? ? ? ? ? ? ? <webResources>
? ? ? ? ? ? ? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <directory>src/main/resources</directory>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <targetPath>WEB-INF/classes</targetPath>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <filtering>true</filtering>
? ? ? ? ? ? ? ? ? ? ? ? </resource>
? ? ? ? ? ? ? ? ? ? </webResources>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
?
?
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.codehaus.mojo</groupId>
? ? ? ? ? ? ? ? <artifactId>tomcat-maven-plugin</artifactId>
? ? ? ? ? ? ? ? <version>1.1</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <path>${webapp.contextPath.test}</path>
? ? ? ? ? ? ? ? ? ? <port>${webapp.port.test}</port>
? ? ? ? ? ? ? ? ? ? <urlEncoding>UTF-8</urlEncoding>
? ? ? ? ? ? ? ? ? ? <server>${tomcat.server.test}</server>
? ? ? ? ? ? ? ? ? ? <url>${tomcat.manager.test}</url>
? ? ? ? ? ? ? ? ? ? <uriEncoding>${tomcat.uriEncoding.test}</uriEncoding>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
?
ps: ?<directory>src/main/resources</directory> ?是打包是复制文件的路径 有时候会出现src/main/resources/${package.environment} 的配置 。效果一样即:src/main/resources/${package.environment}下面的文件一起拷贝过来
? ? ? ? ??