Я сделал то же самое, как предложили некоторые блоги. Но все же я не смог решить проблему.
Окружающая среда:
spring - 4.2.5.RELEASE
spring boot - 1.3.3.RELEASE
hikariCP - 2.4.7
@Bean(name="HikariDataSource",destroyMethod = "shutdown")
public DataSource dataSource2() {
HikariConfig config = new HikariConfig();
config.setDriverClassName("oracle.jdbc.OracleDriver");
config.setJdbcUrl("");
config.setUsername("");
config.setPassword("");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.setPoolName("Hikaripool-1");
HikariDataSource ds = new HikariDataSource(config);
return ds;
}
@Bean
public JdbcTemplate getJdbcTemplate() {
return new JdbcTemplate(dataSource2());
}
Исключение:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (null)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
Caused by: javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
Может ли кто-нибудь помочь мне в решении этой проблемы.
Datasource
для вас? - person Stephane Nicoll   schedule 28.08.2016