简体   繁体   中英

Spring boot dependencies error gradle

I have a new spring boot project and I have included some dependencies. The thing is that on the first run the 'rest' and 'jpa' dependencies are working just fine, but on the second run I'm getting a huge error.

dependencies {
compile('org.springframework.boot:spring-boot-starter-cache')
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework.boot:spring-boot-starter-mail')
compile('org.springframework.boot:spring-boot-starter-remote-shell')
compile('org.springframework.boot:spring-boot-starter-social-facebook')
compile('org.springframework.boot:spring-boot-starter-social-twitter')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

The error message it the following(it was too big to paste it here): error msg

I'm using Intelij IDEA 2016.1.1

The important error message from this stack trace seems to be:

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)

It says that you didn't define what database to use (what kind of an where it is located). I guess you need to add some properties to your application.properties file, like:

spring.datasource.url = (URL to your data source)
spring.datasource.driverClassName = (fully qualified class name of your datasource driver)

You could use an H2 in memory database using this:

spring.datasource.url=jdbc:h2:mem:databaseName;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver

Note that you also need to include the dependencies for the database into your Gradle dependencies ( compile('com.h2database:h2') for an H2).

With java-errors like this you see that there are a lot of lines starting with Caused by: , this is because in the code there are many places where the code catched an exception and then threw it again.
To find the real issue you need to take a look at the last Caused by -entry:

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

I cannot say what the issue itself is with the information you gave. But there are some other threads at stackoverflow that handle this message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM