配置maven,打jar包读取外部配置文件
开发直接读取resource下即可
<profile> <id>test</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <environment>test</environment> </properties> <build> <finalName>test-apii</finalName> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude>logback.xml</exclude> <exclude>*.properties</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <classesDirectory>target/classes/</classesDirectory> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.xxx.Application</mainClass> </manifest> <manifestEntries> <!--读取外部配置文件,放到classpath里 --> <Class-Path>config/.</Class-Path> </manifestEntries> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build> </profile>