标签:cto 命令 users 用户名 color password webapp thread 使用
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> </build>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.7.2</version> <configuration> <parallel>methods</parallel> <threadCount>10</threadCount> <argLine>-Dfile.encoding=UTF-8</argLine> <!-- <skip>true</skip> --> <!-- <testFailureIgnore>true</testFailureIgnore> --> </configuration> </plugin>
<parallel>methods</parallel>:方法级并发;
<threadCount>10</threadCount>:是线程数,当前是10;
<argLine>-Dfile.encoding=UTF-8</argLine>:就是参数命令行,这一行很关键。
测试插件有个小问题,它不依赖项目的字符集设置,它依赖于操作系统。如果你用命令行操作,看中文提示测试结果还好。但在win+eclipse(UTF-8设置)下,那就是乱码了;
<skip>true</skip>是忽略测试;
<testFailureIgnore>true</testFailureIgnore>:忽略测试异常;
既然是web项目,就需要打war包,那就需要这个插件:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> <warName>platform</warName> <webappDirectory>${project.build.directory}/platform</webappDirectory> <warSourceDirectory>WebContent</warSourceDirectory> </configuration> </plugin>
<encoding>${project.build.sourceEncoding}</encoding>强制字符集编码
<warName>platform</warName>war包名字——platform.war
<webappDirectory>${project.build.directory}/platform</webappDirectory>产生war前,用于存放构建war包的目录——target/platform。
<warSourceDirectory>WebContent</warSourceDirectory>:我把web工程搞成了eclipse下的WTP类型。我不喜欢maven产生的webapp目录,更喜欢WebContent!
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.4.3</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin>
xml、properties文件都是资源文件,编码的时候遇到中文总要进行转码!用什么编码?UTF-8,那就记得强制<encoding>${project.build.sourceEncoding}</encoding>。
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <charset>${project.build.sourceEncoding}</charset> <url>http://localhost:8080/manager</url> <server>tomcat.server</server> <path>/platform</path> <port>8080</port> <warFile>${project.build.directory}/platform.war</warFile> <warSourceDirectory>WebContent</warSourceDirectory> <uriEncoding>${project.build.sourceEncoding}</uriEncoding> </configuration> </plugin>
<charset>${project.build.sourceEncoding}</charset>:字符集强制编码
<url>http://localhost:8080/manager/text</url>:我这里已经使用了Tomcat7,如果是Tomcat6就不需要/text!
<server>tomcat.server</server>这是个用户名设置,需要配置maven的settings.xml文件:
<servers>
<server>
<id>tomcat.server</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
在tomcat的tomcat-users.xml中补充相关内容:
(1) tomcat7的配置:
<role rolename="manager-gui"/>
<role rolename="magager-script"/>
<user username="admin" password="123456" roles="manager-gui,manager-script" />
(2) tomcat6的配置:
<role rolename="manager"/>
<user username="admin" password="123456" roles="manager" />
<port>8080</port>:运行时端口
<path>/platform</path>:是运行时路径——http://host:port/platform
<warFile>${project.build.directory}/platform.war</warFile>:我们以war包方式发布,需要指定war包路径。
<warSourceDirectory>WebContent</warSourceDirectory>:同时要指定war包源码路径。这里我使用eclipse的WTP类型工程WebContent目录。
<uriEncoding>${project.build.sourceEncoding}</uriEncoding>:强制字符集编码!
#Run Tomcat
mvn tomcat:run
#Stop Tomcat
#Deploy Tomcat
mvn tomcat:deploy
#Undeploy Tomcat
mvn tomcat:undeploy
#Redeploy Tomcat
mvn tomcat:redeploy
最常用的就是mvn tomcat:run 跟 mvn tomcat:redeploy。
标签:cto 命令 users 用户名 color password webapp thread 使用
原文地址:https://www.cnblogs.com/myitnews/p/11478826.html