5

As mentioned in the headline of question I am facing issue Cannot determine embedded database driver class for database type NONE. The application I have built is on spring boot and working fine when I run the code in intellij.

I have followed several questions regarding the same exception and they suggested that I need to add spring.datasource properties in my application.properties file. I already have them and still facing the same issue. This issue occurs when I create jar file using artifacts of intellij and then run it by the following command. java - jar myJar.jar

My application.properties file

# ===============================
# = DATA SOURCE
# ===============================
spring.datasource.url = jdbc:mysql://localhost:3306/db_wssmith?useSSL=false
spring.datasource.username = 
spring.datasource.password = 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

Error Log while running jar

ERROR org.springframework.boot.SpringApplication - Application startup failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. 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).

9
  • where is your application.properties file located ? Commented Jul 28, 2017 at 12:25
  • 1
    in the project in intellij it is in src/main/resources, in the jar when i open it using winrar its not in any folder its outside folders Commented Jul 28, 2017 at 12:26
  • ok. During the datasource bean creation, spring starts by reading the driver class name property. This exception is thrown when he can't manage to read the datasource properties. try to run it using mvn spring-boot:run, make sure you don't have another application.properties file under config folder (outside of your jar file) .Do you have any Datasource bean configured in your project ? . Can you post the content of your pom.xml (even if i don't think it may be the problem) Commented Jul 28, 2017 at 12:40
  • trying to run it with mvn spring boot command, i didnt understand the part of config folder... i dont have any such folder where my jar is replaced Commented Jul 28, 2017 at 12:42
  • 1
    if you build your jar using maven command instead of using intellij, the java -jar yourjar.jar works ? just to be sure that this is linked to intellij maven conf. Commented Jul 28, 2017 at 12:59

1 Answer 1

3

You should create the jar from maven, to do that go to View on top then Tool Windows/Maven Projects and from there double click on install in LifeCycle option in maven. Use the jar created by that command instead of using intellij. It Should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.