lorsque j'utilise la commandeau sujet du printemps Profil de démarrage ne peut pas travailler
printemps-boot mvn: run = -Dspring.profiles.active web
mon projet est en cours d'exécution, mais @Profile("web")
code haricots non utilisé, qui utilisent uniquement propriétés que le écriture de haricot par
@Profile("default")
comment puis-je changer pour cela, et les propriétés changent de profil web?
@Profile("default")
@Bean
static public PropertySourcesPlaceholderConfigurer defaultPropertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
Resource[] resourceLocations = new Resource[] { new ClassPathResource("job.core.properties") };
p.setLocations(resourceLocations);
return p;
}
@Profile("web")
@Bean
static public PropertySourcesPlaceholderConfigurer prodWebPropertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
Resource[] resourceLocations = new Resource[] {new ClassPathResource("job.core.ris.properties") };
p.setLocations(resourceLocations);
return p;
}
job.core.ris.properties
db.driverClass=com.mysql.jdbc.Driver
db.jdbcUrl=jdbc:mysql://192.168.0.68:3306/job_ris?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8
db.user=root
db.password=
job.core.properties
db.driverClass=com.mysql.jdbc.Driver
db.jdbcUrl=jdbc:mysql://192.168.0.68:3306/dev?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8
lorsque j'utilise l'action puis, montrer ce
Pourquoi les méthodes annotées '@ Bean' sont-elles statiques? Essayez d'enlever le 'static' – StanislavL
si enlever statique le jdbcUrl sera nul –