0

My question is very tricky. Actually, my spring-boot project is ok one way: ./gradlew bootRun is can start another way: Run Application is not ok

I guess spring-boot set default config not effective, but I don't know solve it.

yml config and code

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).`


Yugerten
  • 878
  • 1
  • 11
  • 30
  • Hi, have you checked similar questions? For example: https://stackoverflow.com/questions/24074749/spring-boot-cannot-determine-embedded-database-driver-class-for-database-type Could you please tell us what have you tried so far? Regards, – ronnyfm Jan 25 '19 at 02:00
  • I saw most of the similar problems but it didn't seem to be the same as me. I tried a new IDEA, a new repo, another similar repo (this works fine). – ss zhang Jan 25 '19 at 03:11

1 Answers1

2

Try to add MySql JDBC Driver dependency in your Gradle file

Yugerten
  • 878
  • 1
  • 11
  • 30
  • compile group: 'org.springframework', name: 'spring-jdbc', version:'5.0.8.RELEASE', compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'. This project was originally there. – ss zhang Jan 25 '19 at 03:14