W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
profile
?,它的誕生主要是為了解決不同環(huán)境所需的不同變量、配置等問題。profile
?,可以根據(jù)激活的條件,啟動(dòng)不同條件下的配置信息。profile
?是可以有多個(gè)的,也可以同時(shí)激活多個(gè) ?profile
?,方便自由組合。profile
? 一般可以在三個(gè)地方:?settings.xml
?,?pom.xml
?,?profiles.xml
?(這個(gè)不常用)settings.xml
? 上,一般大家用來做倉庫的選擇,比如以下? settings.xml
?代碼:<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\maven\my_local_repository</localRepository>
<pluginGroups> </pluginGroups>
<proxies> </proxies>
<profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <url>http://192.168.1.73:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <url>http://192.168.1.73:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> <profile> <id>aliyun</id> <repositories> <repository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles>
<activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
</settings>
profile
? 就做一件事:設(shè)置全局的 ?profile
?,一個(gè)是 ?nexus
?倉庫,一個(gè)是 ?aliyun
?倉庫,默認(rèn)激活的是 nexus 倉庫。(?activeProfiles
?)pom.xml
?中,一般用來激活環(huán)境配置,比如以下代碼:<profiles> <profile> <id>dev</id> <properties> <package.environment>dev</package.environment> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/env/${package.environment}</directory> <includes> <include>**/*</include> </includes> <filtering>true</filtering> </resource> </resources> <finalName>${project.artifactId}</finalName> </build> </profile> <profile> <id>product</id> <properties> <package.environment>product</package.environment> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/env/${package.environment}</directory> <includes> <include>**/*</include> </includes> <filtering>true</filtering> </resource> </resources> <finalName>${project.artifactId}</finalName> </build> </profile></profiles>
profile
?就做一件事:打包的時(shí)候,默認(rèn)是 ?dev
?模式,打包 ?src/main/env/dev
? 下的配置文件,如果選擇 ?product
? 則打包 ?src/main/env/product
? 下的配置文件。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: