打包到服务器
<distributionManagement>
<repository>
<id>releases</id>
<name>internal releases</name>
<url>http://ip:1081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>internal snapshot</name>
<url>http://ip:1081/nexus/content/repositories/snapshots</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
以来
<repositories>
<repository>
<id>apache.snapshots.https</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<!--<releases>-->
<!--<enabled>true</enabled>-->
<!--</releases>-->
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
</repository>
<repository>
<id>maven-public</id>
<name>maven-public</name>
<url>http://ip:10081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<!--<releases>-->
<!--<enabled>true</enabled>-->
<!--</releases>-->
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<id>dev</id>
<properties>
<activeProfile>dev</activeProfile>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>online</id>
<properties>
<activeProfile>online</activeProfile>
</properties>
</profile>
</profiles>
<build>
<finalName>tbk-server-start</finalName>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>application.properties</include>
<include>bootstrap.properties</include>
<include>application-${activeProfile}.properties</include>
<include>bootstrap-${activeProfile}.properties</include>
</includes>
<!-- 使用package.target值,替换配置文件中 @activeProfile@ -->
<filtering>true</filtering>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>bin/**</include>
<include>mapper/**</include>
<include>static/**/*</include>
<include>templates/**</include>
<include>**/*.xml</include>
</includes>
<!-- 使用package.target值,替换配置文件中 @activeProfile@ -->
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.tbk.server.Application</mainClass>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 中 Class-Path 加入资源文件目录 -->
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
<!--打包排除项-->
<excludes>
<exclude>**/*.yml</exclude>
<exclude>**/*.properties</exclude>
<exclude>bin/**</exclude>
<exclude>mapper/**</exclude>
<exclude>static/**</exclude>
<exclude>templates/**</exclude>
<exclude>**/*.xml</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<!-- The configuration of the plugin -->
<configuration>
<!-- Specifies the configuration file of the assembly plugin -->
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
spring boot 父子工程子项目无main.class
<!-- 该插件的主要功能是进行项目的打包发布处理 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 设置程序执行的主类 -->
<configuration>
<!-- 为true:代表maven打包时会将外部引入的jar包打包到项目jar,在服务器上项目才能运行,
不加此配置,本地可以运行,因为本地可以再lib下找到外部包,但是服务器上jar中是没有的; -->
<includeSystemScope>true</includeSystemScope>
<mainClass>com.example.SunJarApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<!-- 个人认为重新打包会自动检测到入口类。本项目必须指定,不指定就会报没有主清单属性-->
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
网友评论