首页 > 解决方案 > 如何在 Spring Boot War 中包含特定的 applicaction.properties

问题描述

我需要为 spring boot 项目创建不同的应用程序属性,并在生成的战争中包含正确的属性。我能够产生战争,但不能在其中包含正确的文件。我创建了不同的配置文件,并且在模式 application-env.properties 之后创建了不同的 application.properties,其中 env 是(dev,cert ...),然后所有这些都放在 src/main/resources 但我无法选择正确的一个并包含在生成的战争中,甚至包括“-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>

在此处输入图像描述

标签: javaspring-bootmavenwarprofile

解决方案


推荐阅读