zoukankan      html  css  js  c++  java
  • maven项目配置框架

    任何一个maven项目都会继承一个默认的父pom配置:Super POM,详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html
    在pom.xml中可以直接使用一些变量值,如:

    ${project.groupId}               The group id of current project
    ${project.version}          The version of current project
    ${project.build.sourceDirectory} The source directory of current project
    ${project.basedir}               The directory that the current project resides in.
    ${project.baseUri}               The directory that the current project resides in, represented as an URI. Since Maven 2.1.0
    ${maven.build.timestamp}         The timestamp that denotes the start of the build. Since Maven 2.1.0-M1
    

    详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html之Available Variables

    一个实际完整的maven项目pom.xml文件配置框架:

    <?xml version="1.0"?>
    <project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <modelVersion>4.0.0</modelVersion>
        
        <!-- 模块参数 -->
        <artifactId>xxx-xxx</artifactId>
        <version>x.x.x</version>
        <packaging>war</packaging>
        <name>xxx</name>
        <url>xxx</url>
        
        <!-- 父模块,可选. -->
        <parent>
            <groupId>xxx</groupId>
            <artifactId>xxx</artifactId>
            <version>x.x.x</version>
        </parent>
    
        <!-- 定义属性 -->
        <properties>
            <!-- 项目编码 -->
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <!-- 时间格式 -->
            <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
        </properties>
    
        <!-- 依赖配置 -->
        <dependencies>
            <dependency>
                <groupId>xxx</groupId>
                <artifactId>xxx</artifactId>
                <version>x.x.x</version>
            </dependency>
        </dependencies>
    
        <!-- 定义profile: 将开发配置和生产配置分离开 -->
        <profiles>
            <profile>
                <id>dev</id>
                <properties>
                    <profile.dir>dev</profile.dir>
                </properties>
                <activation>
    				<activeByDefault>dev</activeByDefault>
    			</activation>
            </profile>
            <profile>
                <id>test</id>
                <properties>
                    <profile.dir>test</profile.dir>
                </properties>
            </profile>
            <profile>
                <id>prod</id>
                <properties>
                    <profile.dir>prod</profile.dir>
                </properties>
            </profile>
        </profiles>
    
        <!-- 打包 -->
        <build>
            <finalName>xxx</finalName>
            
            <!-- 打包资源 -->
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <excludes>
                        <exclude>.svn</exclude>
                        <exclude>.java</exclude>
                    </excludes>
                </resource>
                <resource>
                    <directory>src/main/resources/profiles/${profile.dir}</directory>
                    <excludes>
                        <exclude>.svn</exclude>
                    </excludes>
                </resource>
            </resources>
            
            <!-- 配置打包插件,如: 依赖处理,资源复制,压缩打包等 -->
            <plugins>
                <!-- 生成jar包时打包资源文件配置 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.0.2</version>
                    <configuration>
                        <excludes>
                            <exclude>**/profiles/**</exclude>
                            <exclude>**/jdbc.properties</exclude>
                            <exclude>**/*.proto</exclude>
                        </excludes>
                    </configuration>
                </plugin>
    
                <!-- 打包源码 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    
                <!-- 打包编译参数 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
    
                <!-- 将依赖模块的jar包文件提取出来放到指定位置 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>unpack</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>com.xxx</groupId>
                                        <artifactId>xxx-xxx</artifactId>
                                        <version>1.0.0</version>
                                        <type>jar</type>
                                        <includes>**/*.class</includes>
                                        <overWrite>false</overWrite>
                                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    
                <!-- 打包可执行jar文件 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>org.chench.Main</mainClass>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    
                <!-- 构建时不执行单元测试 -->
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-surefire-plugin</artifactId>
    				<version>2.20.1</version>
    				<configuration>
    					<skipTests>true</skipTests>
    				</configuration>
    			</plugin>
            </plugins>
        </build>
    </project>
    
  • 相关阅读:
    利用jquery获取html中被选中的input的值
    获取表单选中的值(利用php和js两种方式)
    复习
    Ajax请求中的async:false/true的作用
    Jquery
    C#创建控制台项目引用Topshelf的方式,部署windows服务。
    你循环的时候就可以给他们赋值了,那么就不用addClass,再根据类选择器处理,代码能一气呵成就别写成两段了
    SQL server 数据库中插入中文变???格式乱码的问题另一种容易忽略的情况(C#操作dapper)
    SQL 两个表有关联,通过其中一个表的列,更新另一个表的列。
    SQL server 存储过程中 列传行
  • 原文地址:https://www.cnblogs.com/nuccch/p/7723151.html
Copyright © 2011-2022 走看看