zoukankan      html  css  js  c++  java
  • spring boot 启动错误:Could not resolve placeholder

     

    在启动整个spring boot项目时,出现错误: 
    Could not resolve placeholder

    原因:没有指定好配置文件,因为src/main/resources下有多个配置文件,例如application-dev.properties, boss.properties等。

    解决办法: 
    法1: 
    在application.properties中加入

    spring.profiles.active=@env@

    用来自动决定选择哪个配置文件。

    法2:(不是好方法)

    @Configuration
    @EnableTransactionManagement
    // 自己添加的,指定配置文件
    @PropertySource(value = "classpath:application-dev.properties", ignoreResourceNotFound = true)
    public class DruidDBConfig {
    
        private static final Logger LOG = LoggerFactory.getLogger(DruidDBConfig.class);
    
        @Value("${spring.datasource.url}")
        private String dbUrl;
    
        @Value("${spring.datasource.username}")
        private String username;
        。。。
    }
  • 相关阅读:
    周总结
    周总结
    周总结
    读后感
    周总结
    周总结
    周总结
    第一周总结
    大学生失物招领平台使用体验
    快速乘法+快速幂
  • 原文地址:https://www.cnblogs.com/williamjie/p/9300226.html
Copyright © 2011-2022 走看看