[英]spring boot project: application run failed but gradle bootRun is ok in idea IDE
我的問題很棘手。 實際上,我的spring-boot
項目可以用一種方式: ./gradlew bootRun
是可以啟動的另一種方式: Run Application
不可以
我想spring-boot
設置默認配置無效,但我不知道解決它。
yml配置和代碼
spring: datasource: url: jdbc:mysql://localhost/test username: root
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
Resource mybatisResource = new ClassPathResource("mybatis-config.xml", Application.class.getClassLoader());
factoryBean.setConfigLocation(mybatisResource);
SqlSessionFactory sessionFactory = null;
try {
sessionFactory = factoryBean.getObject();
} catch (Exception e) {
log.error("init sqlSessionFactory failed.", e);
}
return sessionFactory;
}
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).`
嘗試在您的Gradle文件中添加MySql JDBC Driver dependency
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.