常用的maven配置

<project 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/maven-v4_0_0.xsd"&gt;
<modelVersion>4.0.0</modelVersion>
<groupId>com.qinhailin</groupId>
<artifactId>jfinal-layui</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>jfinal-layui</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>

<!-- 使用阿里 maven 庫 -->
<repositories>
    <repository>
        <id>ali-maven</id>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <!-- undertow -->
    <dependency>
        <groupId>com.jfinal</groupId>
        <artifactId>jfinal-undertow</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>com.jfinal</groupId>
        <artifactId>jfinal</artifactId>
        <version>3.7</version>
    </dependency>

    <!-- 避免控制檯輸出如下提示信息:
         SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
         項目中實際上用不到這個 jar 包
         注意:eclipse 下可以將 scope 設置爲 provided
         -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>1.7.25</version>
        <!-- 打包前改成 provided,此處使用 compile 僅爲支持 IDEA -->
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>1.1.12</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.54</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.44</version>
    </dependency>
    <dependency>
        <groupId>com.jfinal</groupId>
        <artifactId>cos</artifactId>
        <version>2017.5</version>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.6.11</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.17</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk16</artifactId>
        <version>1.44</version>
    </dependency>

</dependencies>
<build>
    <!-- <finalName>jfinal-layui</finalName> -->

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
                <!-- java8 保留參數名編譯參數 -->
                <compilerArgument>-parameters</compilerArgument>
                <compilerArguments><verbose /></compilerArguments>
            </configuration>
        </plugin>

        <!--
            jar 包中的配置文件優先級高於 config 目錄下的 "同名文件"
            因此,打包時需要排除掉 jar 包中來自 src/main/resources 目錄的
            配置文件,否則部署時 config 目錄中的同名配置文件不會生效
         -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <excludes>
                    <exclude>*.txt</exclude>
                    <exclude>*.xml</exclude>
                    <exclude>*.properties</exclude>
                </excludes>
            </configuration>
        </plugin>

        <!-- 
            使用 mvn clean package 打包 
            更多配置可參考官司方文檔:http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html
        -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>

                    <configuration>
                        <!-- 打包生成的文件名 -->
                        <finalName>${project.artifactId}</finalName>
                        <!-- jar 等壓縮文件在被打包進入 zip、tar.gz 時是否壓縮,設置爲 false 可加快打包速度 -->
                        <recompressZippedFiles>false</recompressZippedFiles>
                        <!-- 打包生成的文件是否要追加 release.xml 中定義的 id 值 -->
                        <appendAssemblyId>true</appendAssemblyId>
                        <!-- 指向打包描述文件 package.xml -->
                        <descriptors>
                            <descriptor>package.xml</descriptor>
                        </descriptors>
                        <!-- 打包結果輸出的基礎目錄 -->
                        <outputDirectory>${project.build.directory}/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

</project>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章