1

我们正在运行spring boot version 1.5.10

JDK : 1.8.0.52

我们的 gradle 文件有条目

compile group: 'org.springframework.security', name: 'spring-security-web', version: '4.2.3.RELEASE'

我们在 application.properites 中禁用了它

management.security.enabled=false

我们application-production.properties用来设置生产变量

当我们在生产环境中运行时,值不受影响

我们是否需要再次显式设置它application-production.properties

4

1 回答 1

0

您可以使用许多配置文件并将您的设置拆分为任何文件。对于默认启动应用程序将获得来自 application.properties 的所有设置,对于使用“production”-profile 进行生产运行,并将添加到来自 application-production.properties 的默认新设置中,因为测试将使用 application-test.properties 并使用测试运行配置文件命令。

添加到 pom.xml 类似这种风格的东西

<profiles>
    <profile>
        <id>h2</id>
        <properties>
            <activatedProperties>h2</activatedProperties>
        </properties>
    </profile>
    <profile>
        <id>postgres</id>
        <properties>
            <activatedProperties>postgres</activatedProperties>
        </properties>
    </profile>
</profiles>

在 application.properties 中找到 spring.profiles.active=@activeProfiles@ 并使用配置文件运行

或者您只能使用一个设置文件 = 一个配置文件,请参见示例https://stackoverflow.com/a/25674407/2662111

于 2018-09-06T09:29:22.113 回答