我正在尝试将我的Spring
应用程序连接到Microsoft SQL Server
数据库,但我收到以下错误:
Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause
java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
我已经尝试删除 jdk的certpath 设置为空白,例如: jdk.certpath.disabledAlgorithms=
这是我的配置:
@Configuration
@EnableJpaRepositories("com.abc.cet.eai.repository.sql")
@PropertySource("classpath:eai.application.properties")
public class JpaConfig {
@Bean
public DataSource dataSource() {
SQLServerDataSource dataSource = new SQLServerDataSource();
dataSource.setServerName("SERVERNAME");
dataSource.setUser("USERNAME");
dataSource.setPassword("PASSWORD");
dataSource.setDatabaseName("DATABASE_NAME");
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setPackagesToScan("com.abc.cet.eai.domain");
factory.setDataSource(dataSource());
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setJpaProperties(additionalProperties());
return factory;
}
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(entityManagerFactory().getObject());
return txManager;
}
public Properties additionalProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServer2008Dialect");
return properties;
}
}
有人解决了类似问题吗?
您基本上经历了与我在Wagon-470中相同的问题。用MD5创建的证书材料被现代Java拒绝。您应该检查证书本身,服务器提供的密码并启用JSSE调试选择。您可能需要使用更安全的方法更新/交换证书,例如SHA256。