赞
踩
SpringBoot 自带模块可单独打包成可运行的jar,对于拥有整套微服务框架的企业来说是非常友好的,只需要一个配置中心,完美解决不同环境不同配置的问题,但对于只使用SpringBoot的企业来说,需要配置跟着环境走,所以百度各方资料,整理出相关配置项,让你的SpringBoot 应用可以各目录分离
执行打包命令:
mvn clean package
在当前target目录下生成程序包:
cn-rongplus-msg-receive.tar.gz
解压后查看目录结构:
- ls -al
- total 8
- drwxr-xr-x 8 liugang staff 256 Aug 22 16:17 .
- drwxr-xr-x 13 liugang staff 416 Aug 22 16:17 ..
- -rwxr-xr-x 1 liugang staff 646 Jul 29 13:40 README.md
- drwxr-xr-x 4 liugang staff 128 Aug 22 16:17 bin
- drwxr-xr-x 3 liugang staff 96 Aug 22 16:17 boot
- drwxr-xr-x 6 liugang staff 192 Aug 22 16:17 conf
- drwxr-xr-x 90 liugang staff 2880 Aug 22 16:14 lib
- drwxr-xr-x 2 liugang staff 64 Aug 22 16:14 logs
程序pom 配置如下:
- <properties>
- <main-class>cn.rongplus.msg.Bootstrap</main-class>
- </properties>
-
- <build>
- <finalName>rongplus-receive-${project.version}</finalName>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>version.txt</include>
- <include>mapper/**/*.xml</include>
- <include>static/**</include>
- <include>templates/**</include>
- <include>META-INF/**</include>
- <include>*.xml</include>
- <include>*.yml</include>
- <include>*.properties</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot-version}</version>
- <configuration>
- <layout>ZIP</layout>
- <mainClass>cn.rongplus.msg.Bootstrap</mainClass>
- <includes>
- <!-- 项目启动jar包中排除依赖包 -->
- <include>
- <groupId>non-exists</groupId>
- <artifactId>non-exists</artifactId>
- </include>
- </includes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <encoding>${file_encoding}</encoding>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven_compiler_version}</version>
- <configuration>
- <source>${java_source_version}</source>
- <target>${java_target_version}</target>
- <encoding>${file_encoding}</encoding>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <archive>
- <!-- 添加maven 描述 -->
- <addMavenDescriptor>false</addMavenDescriptor>
- <manifest>
- <!-- 项目启动类 -->
- <mainClass>${main-class}</mainClass>
- <!-- 依赖的jar的目录前缀 -->
- <classpathPrefix>../lib</classpathPrefix>
- <addClasspath>true</addClasspath>
- </manifest>
- <manifestEntries>
- <!-- 此处手工将第三方依赖的jar添加到 META-INF/MANIFEST.MF 清单 多个用空格分隔 -->
- <Class-Path>.</Class-Path>
- </manifestEntries>
- </archive>
- <includes>
- <!-- 只打包指定目录的文件 -->
- <include>cn/rongplus/**</include>
- </includes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。