欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-05-02 09:40:06
...

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