【问题标题】:Spring boot embedded tomcat ServerProperties bean not workingSpring Boot嵌入式tomcat ServerProperties bean不起作用
【发布时间】:2019-03-01 00:24:02
【问题描述】:

我正在开发一个 Spring Boot 应用程序,我使用 ServerProperties 来处理从我的 application.properties 读取的属性问题是 bean ServerProperties 运行良好我的本地机器,但是当我使用 docker tomcat 进入集成阶段时,忽略了这个 bean 修改的值,就像它不存在一样

这是我的豆

    @Value("${server.ssl.key-store-password}")
    private String embeddedTomcatKeyStorePassword ;

    @Value("${server.ssl.trust-store-password}")
    private String embeddedTomcatTrustStorePassword ;
    @Bean
         @Scope("singleton")
         public ServerProperties serverProperties() {
                final ServerProperties serverProperties = new ServerProperties();
                final Ssl ssl = new Ssl();

                log.info("server.ssl.key-store-password : ");
                final String keystorePassword   = Password.recoverPassword(embeddedTomcatKeyStorePassword);
                log.info("server.ssl.trust-store-password : ");
                final String trustStorePassword = Password.recoverPassword(embeddedTomcatTrustStorePassword);

                ssl.setKeyPassword(keystorePassword);
                ssl.setTrustStorePassword(trustStorePassword);

                serverProperties.setSsl(ssl);
                return serverProperties;
            }


server.ssl.key-store-password=f340b6a8c8b6ba0f1a5110b304cafeba14793c34b7fcc84d6c3dc8f2ddabdbf3
server.ssl.trust-store-password=3a572f3cd9010831a85150137b6481fbb815347e87cd634be08ef6c95599826d

有人可以向我解释为什么这个解决方案在本地开发人员上工作,而在我使用 docker 部署应用程序时不起作用,提前谢谢

【问题讨论】:

    标签: java spring spring-mvc docker spring-boot


    【解决方案1】:

    检查您的本地 tomcat 运行配置,可能您使用了一些 VM 选项或其他环境变量,例如 -Dspring.profiles.active,但没有在 docker 运行配置中使用它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-28
      • 1970-01-01
      • 2017-03-12
      • 2018-06-27
      • 1970-01-01
      • 2015-03-23
      • 2016-12-28
      • 1970-01-01
      相关资源
      最近更新 更多