maven的profile设置

<build>
				<filters>
					<filter>profiles/km-prod/build.properties</filter>
				</filters>
				<resources>
					<resource>
						<directory>src/main/resources</directory>
						<filtering>true</filtering>
					</resource>
					<resource>
						<directory>profiles/km-prod/conf</directory>
						<filtering>true</filtering>
					</resource>
					<resource>
						<directory>profiles/km-prod/test</directory>
					</resource>
				</resources>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-war-plugin</artifactId>
						<version>2.4</version>
						<configuration>
							<webResources>
								<resource>
									<directory>${webXmlPath}</directory>
									<targetPath>WEB-INF</targetPath>
								</resource>
								<resource>
									<directory>profiles/km-prod/webapp/static</directory>
									<targetPath>static</targetPath>
								</resource>
								<resource>
									<directory>profiles/km-prod/webapp/resources</directory>
									<targetPath>resources</targetPath>
								</resource>
							</webResources>
							<warSourceExcludes>fedev/**</warSourceExcludes>
						</configuration>
					</plugin>
				</plugins>
			</build>



profile的配置文件如下所示:
maven的profile设置_第1张图片

classes的目录下面:
maven的profile设置_第2张图片


在static目录下面:
maven的profile设置_第3张图片


在resources/css/build下面


maven的profile设置_第4张图片
1、filtering为true的话,直接用build.properties里面的参数进行覆盖,
					<resource>
						<directory>profiles/km-prod/conf</directory>
						<filtering>true</filtering>
					</resource>



2、设置resource的,默认是覆盖在classes中下面的,不能跨越 classes 上面的目录
<resource>
						<directory>profiles/km-prod/test</directory>
					</resource>

3、如果要覆盖classes上面的目录,比如静态资源,web.xml等等。可以使用maven-war-plugin插件
<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-war-plugin</artifactId>
						<version>2.4</version>
						<configuration>
							<webResources>
								<resource>
									<directory>${webXmlPath}</directory>
									<targetPath>WEB-INF</targetPath>
								</resource>
								<resource>
									<directory>profiles/km-prod/webapp/static</directory>
									<targetPath>static</targetPath>
								</resource>
								<resource>
									<directory>profiles/km-prod/webapp/resources</directory>
									<targetPath>resources</targetPath>
								</resource>
							</webResources>
							<warSourceExcludes>fedev/**</warSourceExcludes>
						</configuration>
					</plugin>
				</plugins>








你可能感兴趣的:(maven的profile设置)