Maven pom.xml配置

来源:互联网 发布:jenkins pipeline node 编辑:程序博客网 时间:2024/06/10 06:30

<!-- pom.xml 文件名 -->

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>yihaodian</groupId>
    <artifactId>search</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>search</name>
    <url>http://maven.apache.org</url>

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

       <dependencies>

        <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope><!-- 只在测试时使用,用于编译和运行测试代码。不会随项目发布 -->
</dependency> 

        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>javax.servlet.jsp.jstl</artifactId>
            <version>1.2.2</version>
            <!--  去掉jsp-api和servlet-api传递依赖,tomcat自身包含,解决not load问题-->
            <!-- MyEclipse pom.xml视图Dependency Hierarchy选择Exclude Maven Artifact...-->
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>jsp-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
 </dependencies>
 
<build>
 
<!--将src/main/java中的xml与properties打入jar包中-->
<!-- 注:src/main/resources中的文件默认打入classes即jar包中,
        因此src/main/java所有配置信息最好写入resources中,建立同级目录即可,不用单独配置此项 -->
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
        </resource>
    </resources>
 
    <plugins>
<!--配置jdk编译环境1.7,默认1.5需要更改-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>UTF8</encoding>  
            </configuration>
        </plugin>
<!--deploysource 源代码-->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <attach>true</attach>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--deployjavadoc doc文档-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <charset>UTF-8</charset>
                    <docencoding>UTF-8</docencoding>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <distributionManagement>
    <!--根据version选择发布到snapshots或releases-->
        <!--发布到snapshots-->
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
        <!--发布到releases-->
        <repository>
         <id>releases</id>
             <url>http://localhost:8081/nexus/content/repositories/releases</url>
         </repository>
    </distributionManagement>
</project>

0 0
原创粉丝点击