简体   繁体   中英

How to use spring-jdbc in Quarkus?

Could you please let me know how to use spring-jdbc in Quarkus, as I am converting my application from spring to Quarkus, for now I required to use JdbcTemplate but I don't see how to use it.

I am using below dependencies:

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-spring-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-spring-web</artifactId>
</dependency>

But I didn't find anything for spring-jdbc

There isn't such thing as JdbcTemplate in Quarkus, nor a support for spring-jdbc .

So the answer is that you cannot use them, you need to convert the usage to Spring Data (or HIbernate with Panache), or inject a DataSource object and directly work with it.

We found that past version works perfectly fine with native compilation. Hope that's good enough in your case. Replacing logging is also required for native compilation, because of Class.forName usages.

<spring.jdbc.version>4.3.30.RELEASE</spring.jdbc.version>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>${spring.jdbc.version}</version>
  <exclusions>
    <exclusion>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>

<dependency>
  <groupId>org.jboss.logging</groupId>
  <artifactId>commons-logging-jboss-logging</artifactId>
</dependency>

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