spring-boot executable jar,启动报错:AnnotationConfigEmbeddedWebApplicationContext has not been refreshed yet

MR_TS 发布于 2016/12/15 13:43
阅读 10K+
收藏 0

spring-boot 构建项目,正常Application在ecilpse中启动没有问题,平时一直war部署也是没有问题的;

最近再尝试打成可执行jar,java -jar xxx.jar 一执行就循环报错,集中在数据库那块;

配置如下:

@Configuration
@EnableTransactionManagement
@MapperScan("com.meix.manage.dao")
public class MybatisConfig implements TransactionManagementConfigurer {

@Bean
public DataSource SimpleDataSource(){
DataSource ds = null;
try{
ds = new SimpleDriverDataSource(new ReplicationDriver(),"jdbc:mysql:replication://127.0.0.1:3326,127.0.0.1:3336/xxx?characterEncoding=utf8","xx","xxx");
System.out.println("---------------"+ds.getConnection().toString()+"--------------");
} catch(SQLException e) {
e.printStackTrace();
}
return ds;
}


@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
Properties myBatisConfig=new Properties();
myBatisConfig.setProperty("logImpl", "SLF4J");
sessionFactory.setConfigurationProperties(myBatisConfig);
sessionFactory.setDataSource(SimpleDataSource());
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sessionFactory.setMapperLocations(resolver
.getResources("classpath:/mybatis/*.xml"));
return sessionFactory.getObject();
}

@Override
public PlatformTransactionManager annotationDrivenTransactionManager() {
return new DataSourceTransactionManager(SimpleDataSource());
}

@Bean(destroyMethod="close")
    public SqlSessionTemplate sqlSessionTemplate() throws Exception {
        return new SqlSessionTemplate(sqlSessionFactory());
    }

}

错误打印:

13:12:17.375 WARN  o.s.b.f.s.DefaultListableBeanFactory - Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'IUserDao' defined in URL [jar:file:/F:/dev2/workspaces2/ia-manage-parent/ia-manage/target/iamanage.jar!/BOOT-INF/classes!/com/meix/manage/dao/IUserDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/meix/manage/config/MybatisConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SimpleDataSource' defined in class path resource [com/meix/manage/config/MybatisConfig.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceInitializer': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Initialization of bean failed; nested exception is java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6d86a830 has not been refreshed yet

加载中
0
skhuhu
skhuhu
datasource配置那有问题··具体的还要调试···看日志就没用了·
0
0
观澜凭岳
观澜凭岳

请问您的问题解决了吗

0
郑毅922
郑毅922

请问问题解决了吗?

返回顶部
顶部