Some common configuration (X)

First, set the project a unified character set encoding

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Second, compile the plugin: specify jdk version and encoding

<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>

Third, test plug-in

<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> : Method level parallelism;
<threadCount> 10 </ threadCount>: is the number of threads currently 10;
<argLine> = UTF--Dfile.encoding. 8 </ argLine>: the parameter is the command line this line is critical.

Test plug-in has a small problem, it does not depend on the character set of project settings, it depends on the operating system. If you use the command line, look good Chinese prompt test results. But in the win + eclipse (UTF-8 is provided), that is distortion;
<Skip> to true </ Skip> is ignored test;
<the testFailureIgnore> to true </ the testFailureIgnore>: Ignore testing exceptions;

Four, war plug-in package

Since it is a web project, you need to fight the war package, it would need this plugin:

<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> force character set encoding
<warName> platform </ warName> war package name --platform.war
<webappDirectory>} $ {project.build.directory / Platform </ before webappDirectory> generating war, for storing the package build directory --target war / platform.
<warSourceDirectory> WebContent </ warSourceDirectory> : I became engaged WTP web project type in eclipse. I do not like webapp directory maven generated prefer WebContent!

Fifth, the allocation of resources plug-in: encoding specified resource

<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 files are resource files, encoded when it came to Chinese always have to be transcoded! What encoding? UTF-8, it is forced to remember <encoding> $ {project.build.sourceEncoding} </ encoding>.

Six, tomcat plug-in

<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>: mandatory character set encoding
<url> http: // localhost: 8080 / manager / text </ url>: I have used here Tomcat7, if it is Tomcat6 You do not need / text!
<server> tomcat.server </ server> This is a user name settings, you need to configure the maven settings.xml file:
<Servers>
  <Server>
    <the above mentioned id> tomcat.server </ the above mentioned id>
    <username> ADMIN </ username>
    < password> 123456 </ password>
  </ Server>
</ Servers>
relevant content in the tomcat tomcat-users.xml in:
(. 1) tomcat7 configuration:
<Role rolename = "GUI-Manager" />
<= Role rolename "magager-Script" />
<User username = "ADMIN" password = "123456" Roles = "GUI-Manager,


<User username = "ADMIN" password = "123456" Roles = "Manager" />
<Port> 8080 </ Port>: Run port
<path> / platform </ path >: Path is the runtime --http: / / Host: Port / Platform
<warFile> $ {} /platform.war project.build.directory </ warFile>: release our war package, the package need to specify the war path.
<warSourceDirectory> WebContent </ warSourceDirectory> : To specify the war package while the source directory. Here I use eclipse WTP type of project WebContent directory.
<uriEncoding> $ {project.build.sourceEncoding} < / uriEncoding>: mandatory character set encoding!

Seven, plug-in command

#Run Tomcat
mvn tomcat:run
#Stop Tomcat
#Deploy Tomcat
mvn tomcat:deploy
#Undeploy Tomcat
mvn tomcat:undeploy
#Redeploy Tomcat
mvn tomcat:redeploy

The most common is mvn tomcat: run with mvn tomcat: redeploy.

 

Guess you like

Origin www.cnblogs.com/myitnews/p/11478826.html