这是我的第一个问题。我会尽量具体的。
首先,我知道有很多关于这个错误的主题,有些是带有解决方案的,,但我的情况不同,因为我不是每次都有这个错误,在cmd中输入ipconfig /renew之后,它就消失了一段时间。那么,现在来谈谈细节。
我在Windows 7工作。
这是我的数据源配置:
package ...;
import ...;
@Configuration
public class DataSourceConfig {
@Value("${db.url}") private String url;
@Value("${db.user}") private String user;
@Value("${db.pass}") private String pass;
@Value("${db.poolSize.init}") private int initPoolSize;
@Value("${db.poolSize.min}") private int minPoolSize;
@Value("${db.poolSize.max}") private int maxPoolSize;
@Value("${db.statements.max}") private int maxStatements;
@Value("${db.idleTime.max}") private int maxIdleTime;
@Value("${db.checkoutTimeout}") private int checkoutTimeout;
@Bean
public DataSource oracleDataSource() throws SQLException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl(url);
dataSource.setUser(user);
dataSource.setPassword(pass);
dataSource.setInitialPoolSize(initPoolSize);
dataSource.setMaxPoolSize(maxPoolSize);
dataSource.setMinPoolSize(minPoolSize);
dataSource.setMaxIdleTime(maxIdleTime);
dataSource.setMaxStatements(maxStatements);
dataSource.setCheckoutTimeout(checkoutTimeout);
return dataSource;
}
}JPA配置:
package ...;
import ...;
@Configuration
@EnableJpaRepositories
@EnableTransactionManagement
public class JpaConfig {
@Autowired
private DataSource dataSource;
@Value("${is.ddl.enabled}")
private String isDDLenabled ;
@Bean
public EntityManagerFactory entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(Boolean.valueOf(isDDLenabled));
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("...");
factory.setDataSource(dataSource);
factory.setJpaDialect(new HibernateJpaDialect());
factory.afterPropertiesSet();
return factory.getObject();
}
@Bean
public PlatformTransactionManager Here() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory());
return transactionManager;
}
}我和Jetty一起跑进来的。,当我运行它的前几次,它是好的,。但在8-15分之后,我得到了以下信息:
Failed startup of context ...
org.springframework.beans.factory.BeanCreationException:
...
org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set在此之后,如果我试图运行该项目,则会得到相同的错误,直到在命令行中运行ipconfig /renew命令为止。在那之后,它又运行了8-15次,没有问题。
这里有人遇到过这样的事吗?ipconfig如何影响像这样的项目的运行?请帮帮忙。
发布于 2016-10-03 13:16:30
您使用的是org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter,您应该使用这个org.springframework.orm.jpa.vendor.HibernateJpaDialect
HibernateJpaDialect hibernateJpaDialect =new HibernateJpaDialect();并将工厂对象设置如下:
factory.setJpaVendorAdapter(hibernateJpaDialect);https://stackoverflow.com/questions/39829168
复制相似问题