Tag Archives: could not resolve placeholder error

[How to Fix] Spring boot startup error: could not resolve placeholder

When starting the whole spring boot project, an error occurred:
could not resolve placeholder

Reason: the configuration file is not specified, because there are multiple configuration files under Src/main/resources, such as application- dev.properties , boss.properties And so on.

Solution:
method 1:
in application.properties Join in

spring.profiles.active= @env@

Used to automatically decide which profile to choose.

Method 2: (not a good method)

@Configuration
@EnableTransactionManagement
// Added by yourself, specifying the configuration file
@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;
    。。。
}