gpt4 book ai didi

java - Spring 启动项目: application run failed but gradle bootRun is ok in idea IDE

转载 作者:行者123 更新时间:2023-12-02 01:41:55 30 4
gpt4 key购买 nike

我的问题很棘手。其实我的spring-boot项目没问题 一种方式: ./gradlew bootRun 可以启动 另一种方式:运行应用程序不行

我猜spring-boot设置默认配置不起作用,但我不知道解决它。

yml 配置和代码

Spring :
数据源:
url: jdbc:mysql://localhost/test
用户名:根

   @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 依赖项

关于java - Spring 启动项目: application run failed but gradle bootRun is ok in idea IDE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54357806/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com