微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java spring-boot 错误:“无法解析符号 jdbc”

如何解决java spring-boot 错误:“无法解析符号 jdbc”

我看过

并在网上搜索:“无法解析符号 jdbc”,结果为零。

我更改了 pom.xml 但给出了错误 Dependency 'org.xerial:hsqldb-jdbc:' not found

    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.3.2</version>
        <scope>test</scope>
    </dependency>

    <!-- bellow is not working (red in IDE): -->
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>hsqldb-jdbc</artifactId>
        <version></version>
        <scope>test</scope>
    </dependency>

尝试了更多。

我还能做什么和尝试?

到目前为止,我只在完成的 Spring 应用程序中进行了编程。这应该是我从头开始写的 my first Spring application认值:Jetty、hsqldb)。

解决方法

我不太确定您从哪里获得此 hsqldb-jdbc 依赖项,但它似乎不再在 org.xerial 组中。你可以看到in MVN Repository没有这样的依赖。

据我所知,您需要此依赖项才能成功连接到 HSQLDB。要连接到数据库,请执行以下操作:

  1. 添加没有 test 范围的 HSQLDB,如下所示:
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>2.4.0</version>
</dependency>
  1. 在您的 resources 文件夹中创建 application.properties

对于磁盘数据库:

spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver 
spring.datasource.url=jdbc:hsqldb:hsql://localhost/testdb 
spring.datasource.username=sa 
spring.datasource.password= 
spring.jpa.hibernate.ddl-auto=update

对于内存数据库:

spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create
  1. 创建实体
  2. 创建存储库
  3. 测试一下

看看这个Spring Boot HSQLDB integration tutorial了解更多

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。