Maven 根据不同的环境使用不同的配置

pom文件配置

<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<profile.id>dev</profile.id>
			</properties>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
		</profile>
		<profile>
			<id>test</id>
			<properties>
				<profile.id>test</profile.id>
			</properties>
		</profile>
		<profile>
			<id>preonline</id>
			<properties>
				<profile.id>preonline</profile.id>
			</properties>
		</profile>
		<profile>
			<id>online</id>
			<properties>
				<profile.id>online</profile.id>
			</properties>
		</profile>
	</profiles>
	<build>
		<finalName>middlewares</finalName>
		<resources>
			<resource>
				<directory>src/main/resources/env</directory>
				<includes>
					<include>global/*</include>
				</includes>
			</resource>
			<resource>
				<directory>src/main/resources/env</directory>
				<includes>
					<include>${profile.id}/*</include>
				</includes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<id>prepare-war</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>exploded</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

配置文件结构

 

配置文件配置

converter.packageName=${converter.packageName}

 

posted @ 2019-01-18 18:00  BINGJJFLY  阅读(659)  评论(0编辑  收藏  举报