一 pom引入本地包

  <dependency>
		<groupId>oracle</groupId>
		<artifactId>ojdbc6</artifactId>
		<version>11.2.0.3</version>
		<scope>system</scope>
		<systemPath>${project.basedir}/src/lib/ojdbc6-11.2.0.3.jar</systemPath>
</dependency>

二 跳过test打包

 <properties>
        <skipTests>true</skipTests>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 </properties>

三 设置mapper.xml不在resource文件下

还需要对应的yml配置 设置mybatis

mapper-locations: classpath*:com/包名/包名/dao/*Mapper.xml

<build>,
	<resources>
	    <resource>
	        <directory>src/main/java</directory>
	        <includes>
	            <include>**/*.xml</include>
	        </includes>
	        <filtering>true</filtering>
	    </resource>
	</resources>
</build>	

打包配置

没有 repackage 不会生成正常可执行文件

 <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.1.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

设置jdk版本

每个模块都需要添加

  <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

仓库地址

<repositories>
        <repository>
            <id>nexus-aliyun</id>
            <name>Nexus aliyun</name>
            <layout>default</layout>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>


    <repositories>
        <repository>
            <id>public</id>
            <name>huawei nexus</name>
            <url>https://mirrors.huaweicloud.com/repository/maven/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

<repository>
  <id>central</id>
  <url>https://maven.aliyun.com/repository/central</url>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>



   <repositories>
        <repository>
            <id>public</id>
            <name>aliyun nexus</name>
            <url>https://maven.aliyun.com/repository/central</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>


  	 
	 <!--配置阿里云镜像-->
    <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
     </mirror>
	 

配置打包名称

  <build>
        <finalName>${project.artifactId}-1.1.0</finalName>
    </build>

自定义pom版本依赖

<elasticsearch.version>7.7.0</elasticsearch.version>

常用依赖

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.11</version>
</dependency>

修改版本

升级

## mvn versions:set -DnewVersion=1.0.3-SNAPSHOT
mvn versions:set -DnewVersion=1.0.1

回退

mvn versions:revert

版本读取

上面的版本优先读取

安装本地jar包

mvn install:install-file -Dfile=C:\Users\Administrator\Desktop\netpay.jar -DgroupId=CCBSign -DartifactId=RSASig -Dversion=1.0 -Dpackaging=jar

私服


指令

mvn -pl   指定模块打包

mvn -U 强制刷新本地仓库不存在release版和所有的snapshots版本。
-B,-批处理模式以非交互方式运行(批处理)模式(禁用输出颜色)

-f,-file 强制使用备用POM文件(或带有pom.xml的目录),pom文件路径必须紧跟在 -f 参数后面

多环境配置

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
  <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profiles.active>prod</profiles.active>
            </properties>
        </profile>
    </profiles>

配置打包 git记录

 <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>2.2.5</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <prefix>git</prefix>
                    <verbose>false</verbose>
                    <dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
                    </generateGitPropertiesFilename>
                    <format>json</format>
                    <!-- git.commit.id.abbrev属性值的长度,取值范围在[2, 40],默认值7 -->
                    <abbrevLength>7</abbrevLength>
                    <gitDescribe>
                        <skip>false</skip>
                        <always>false</always>
                        <dirty>-dirty</dirty>
                    </gitDescribe>
                </configuration>
            </plugin>
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐