java—如何在spring boot war中包含特定的application.properties

3z6pesqy  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(185)

我需要为spring启动项目创建不同的应用程序属性,并在生成的war中包含适当的属性。我可以生成一个war,但是不能在其中包含正确的文件。我创建了不同的概要文件,并按照模式application-env.properties创建了不同的application.properties,其中env是(dev,cert…),所有这些都放在src/main/resources中,但我无法选择合适的概要文件并包含在生成的war中,甚至包括“-dspring.profiles.active=cert”来定义活动概要文件。这场战争是由他们所有人引起的。你知道吗?

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <build.profile.id>dev</build.profile.id>
            <packaging.type>jar</packaging.type>
            <spring.profiles.active>dev</spring.profiles.active>
        </properties>
    </profile>
    <profile>
        <id>cert</id>
        <properties>
         <build.profile.id>cert</build.profile.id>
            <spring.profiles.active>cert</spring.profiles.active>
            <packaging.type>war</packaging.type>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题