环境
maven2
tomcat7
需求
将本地web项目发布至10.200.187.24指定目录下
pom.xml配置
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://10.200.187.24:8080/manager/html</url>
<server>huaat</server>
<username>hadoop</username>
<password>hadoop</password>
<path>/yunatworkflow</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<id>upload-war</id>
<phase>package</phase>
<goals>
<goal>upload-single</goal>
</goals>
<configuration>
<fromFile>target/yunatworkflow.war</fromFile>
<url>scp://[email protected]/home/admin/apache-tomcat-7.0.41/webapps</url>
<server>huaat</server>
<skip>false</skip>
<toFile>yunatworkflow.war</toFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
注意:上面有两处server必须一致。
tomcat7 http://10.200.187.24:8080/manager/html以html结尾
wagon-maven-plugin组件提供远程发布,支持scp ftp等操作。
maven-compiler-plugin默认版本太低,build异常。
fromFile采用发布后生成war相对pom.xml路径
url 远程机器,注意scp admin@url,
toFile 路径相对于url。
settings.xml配置
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>huaat</id>
<username>hadoop</username>
<password>hadoop</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
</settings>
注意:上面有三处server必须一致。
conf/tomcat-user.xml配置
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user password="hadoop" roles="manager_script,manager-jmx,manager-status,admin-gui,manager-gui" username="hadoop"/>
注意:如上三处username password一致。tomcat7必须配置manager_gui,大部分资料使用manager。
运行命令
mvn tomcat7:deploy