build配置项中maven常用插件

 1 <build>
 2         <!-- 在浏览器地址栏的项目名称 -->
 3         <finalName>${project.artifactId}</finalName>
 4         <!-- 默认的主代码目录 -->
 5         <sourceDirectory>src/main/java</sourceDirectory>
 6         <!-- 默认的测试代码目录 -->
 7         <testSourceDirectory>src/test/java</testSourceDirectory>
 8         <!-- 处理无法加载资源配置文件 -->
 9         <resources>
10             <resource>
11                 <directory>src/main/java</directory>
12                 <includes>
13                     <include>**/*.xml</include>
14                     <include>**/*.properties</include>
15                 </includes>
16             </resource>
17             <resource>
18                 <directory>src/main/resources</directory>
19                 <includes>
20                     <include>**/*.xml</include>
21                     <include>**/*.properties</include>
22                 </includes>
23             </resource>
24         </resources>
25 
26         <plugins>
27 
28             <!-- maven中的编译器,可以指定编译jdk版本 -->
29             <plugin>
30                 <groupId>org.apache.maven.plugins</groupId>
31                 <artifactId>maven-compiler-plugin</artifactId>
32                 <version>3.6.0</version>
33                 <configuration>
34                     <source>${java-version}</source>
35                     <target>${java-version}</target>
36                     <!-- 告诉编译器源码的编码格式 -->
37                     <encoding>${project.build.sourceEncoding}</encoding>
38                 </configuration>
39             </plugin>
40 
41             <!-- web项目整合成war包的插件,需先complie再打war-->
42             <plugin>
43                 <groupId>org.apache.maven.plugins</groupId>
44                 <artifactId>maven-war-plugin</artifactId>
45                 <version>3.1.0</version>
46                 <configuration>
47                     <warName>${project.artifactId}</warName>
48                     <encoding>${project.build.sourceEncoding}</encoding>
49 
50                     <webResources>
51                         <resource>
52                             <directory>src/main/resources</directory>
53                             <targetPath>WEB-INF/classes</targetPath>
54                             <includes>
55                                 <include>**/*.*</include>
56                             </includes>
57                         </resource>
58                     </webResources>
59                 </configuration>
60             </plugin>
61 
62             <!-- maven里的tomcat7小插件,仅开发阶段用 -->
63             <plugin>
64                 <groupId>org.apache.tomcat.maven</groupId>
65                 <artifactId>tomcat7-maven-plugin</artifactId>
66                 <version>2.2</version>
67                 <configuration>
68                     <!-- tomcat管理路径 -->
69                     <url>http://localhost:80/manager/text</url>
70                     <!-- 与settings.xml文件中Server的id相同 -->
71                     <server>tomcat7</server>
72                     <uriEncoding>utf-8</uriEncoding>
73                     <!--服务器端口号80可以省去-->
74                     <port>80</port>
75                     <!-- 应用的部署位置 -->
76                     <path>/</path>
77                     <!-- 实时重载 -->
78                     <contextReloadable>true</contextReloadable>
79                     <systemProperties>
80                         <!-- 控制台显示格式 -->
81                         <java.util.logging.SimpleFormatter.format>[%4$s] %1$tF %1$tT %3$s %5$s %n
82                         </java.util.logging.SimpleFormatter.format>
83                     </systemProperties>
84                 </configuration>
85                 <executions>
86                     <execution>
87                         <id>tomcat-run</id>
88                         <phase>test</phase>
89                         <goals>
90                             <goal>run</goal>
91                         </goals>
92                     </execution>
93                 </executions>
94             </plugin>
95 
96         </plugins>
97     </build>

 

posted @ 2018-03-22 14:27  Schiller_Hu  阅读(367)  评论(0编辑  收藏  举报