【问题标题】:Spring boot dependencies error gradleSpring Boot 依赖项错误 gradle
【发布时间】:2016-09-17 20:41:14
【问题描述】:

我有一个新的 Spring Boot 项目,并且包含了一些依赖项。问题是,在第一次运行时,“rest”和“jpa”依赖项工作得很好,但在第二次运行时,我遇到了一个巨大的错误。

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')
}

错误信息如下(太大,无法粘贴到这里): error msg

我正在使用 Intelij IDEA 2016.1.1

【问题讨论】:

    标签: java gradle spring-boot dependencies


    【解决方案1】:

    像这样的java-errors你会看到有很多行以Caused by:开头,这是因为在代码中有很多地方代码捕获了异常然后再次抛出它。
    要找到真正的问题,您需要查看最后一个 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).
    

    我无法说明您提供的信息本身存在什么问题。但是在 stackoverflow 中有 some other threads 处理此消息。

    【讨论】:

      【解决方案2】:

      此堆栈跟踪中的重要错误消息似乎是:

      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)
      

      它说您没有定义要使用的数据库(它位于什么样的位置)。 我猜你需要在application.properties 文件中添加一些属性,比如:

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

      您可以通过以下方式在内存数据库中使用 H2:

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

      请注意,您还需要将数据库的依赖项包含到您的 Gradle 依赖项中(compile('com.h2database:h2') 用于 H2)。

      【讨论】:

        猜你喜欢
        • 2021-01-04
        • 2020-03-31
        • 1970-01-01
        • 2019-07-26
        • 2015-06-28
        • 1970-01-01
        • 2022-12-23
        • 2019-07-16
        • 2018-01-31
        相关资源
        最近更新 更多