Java教程

配置maven,打jar包读取外部配置文件

本文主要是介绍配置maven,打jar包读取外部配置文件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

配置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>

 

这篇关于配置maven,打jar包读取外部配置文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!