Maven中<resources>标签详解

                    Maven中< resources>标签详解


clean install -DskipTests -P test   传入test参数 
 DskipTests,不执行测试用例
-P test 会激活项目下的pom.xml配置的<profiles>标签下id为test的标签
 <!-- profiles.active默认激活dev -->
  <profiles>
    <profile>
        <!-- 声明这个profile的id身份 -->
        <id>dev</id>
        <!-- 默认激活:比如当知心mvn package命令是,没有传入参数,默认使用这个
                                    当使用mvn package -P dev 传入参数时,表示使用这个id的profile -->
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <!-- 该标签下配置对应的key  value -->
        <properties>
            <!-- 这里的标签名任意,在 项目的 properties、xml等配置文件中可以使用${profiles.active}取出dev这个值-->
            <profiles.active>dev</profiles.active>
        </properties>
    </profile>
    <profile>
        <id>test</id>
        <properties>
            <profiles.active>test</profiles.active>
        </properties>
    </profile>
    <profile>
        <id>pro</id>
        <properties>
            <profiles.active>pro</profiles.active>
        </properties>
    </profile>
  </profiles>


  <build>
    <finalName>com_dubbo_config</finalName>

    <resources>
        <resource>
            <!-- 指定resources插件处理哪个目录下的资源文件 -->
            <directory>src/main/resources</directory>
            <!-- 打包后放在什么位置 -->
            <targetPath>${project.build.directory}/classes</targetPath>
            <!-- 不包含directory指定目录下的以下文件 -->
            <excludes>
                <exclude>pro/*</exclude>
                <exclude>dev/*</exclude>
                <exclude>test/*</exclude>
            </excludes>
            <!-- 只(这个字很重要)包含directory指定目录下的以下文件 
                 <include>和<exclude>都存在的话,那就发生冲突了,这时会以<exclude>为准 -->
            <includes>
                <include></include>
            </includes>
            <!-- filtering为true的时候,这时只会把过滤的文件(<excludes>)打到classpath下,
                 filtering为false的时候,会把不需要过滤的文件(<includes>)打到classpath下 -->
            <filtering>true</filtering>
        </resource>

        <resource>
            <directory>src/main/resources/${profiles.active}</directory>
            <targetPath>${project.build.directory}/classes</targetPath>
        </resource>
    </resources>
  </build>
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值