java 开发 idea spring->resource添加多个资源配置文件夹


环境:dev、test、pre、prod

文件夹:resource-ad、resource-push


最终的样式如下:





1.先建立如上的文件夹结构,并放置相应的property

2.进入pom.xml,添加相应的资源目录:

<resources>
    <resource>
        <directory>src/main/resources-push/resources.${deploy.type}</directory>
        <filtering>true</filtering>
    </resource>
    <resource>
        <directory>src/main/resources-ad/resources.${deploy.type}</directory>
        <filtering>true</filtering>
    </resource>
</resources>


3.pom.xml文件中增加相应的profiles

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <deploy.type>dev</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>dev-ad</id>
            <properties>
                <deploy.type>dev-ad</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <deploy.type>test</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>test-ad</id>
            <properties>
                <deploy.type>test-ad</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>pre</id>
            <!--<activation>-->
                <!--<activeByDefault>true</activeByDefault>-->
            <!--</activation>-->
            <properties>
                <deploy.type>pre</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>pre-ad</id>
            <properties>
                <deploy.type>pre-ad</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <deploy.type>prod</deploy.type>
            </properties>
        </profile>
        <profile>
            <id>prod-ad</id>
            <properties>
                <deploy.type>prod-ad</deploy.type>
            </properties>
        </profile>
    </profiles>


展开阅读全文

没有更多推荐了,返回首页