简体   繁体   中英

java spring-boot Error: “cannot resolve symbol jdbc”

i have read

and searched the web for: "cannot resolve symbol jdbc" with zero results.

I changed pom.xml but gives Error 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>

And tried much much more.

What else i could do and try?

So far I had only programmed in finished Spring applications. This should bemy first Spring application that I write from the beginning (defaults: Jetty, hsqldb).

I'm not really sure where you got this hsqldb-jdbc dependency but it seems that it is no longer in org.xerial group. You can see it in MVN Repository that there is no such dependency.

As far as I understand, you need this dependency to succesfully connect to the HSQLDB. To connect to database, do following:

  1. Add HSQLDB without test scope as follows:
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>2.4.0</version>
</dependency>
  1. Create application.properties in your resources folder

For on-disk database:

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

For in-memory database:

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. Create entities
  2. Create Repositories
  3. Test it all out

Take a look at this Spring Boot HSQLDB integration tutorial for more

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