简体   繁体   English

如何在 Quarkus 中使用 spring-jdbc?

[英]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.您能否让我知道如何在 Quarkus 中使用 spring-jdbc,因为我正在将我的应用程序从 spring 转换为 Quarkus,现在我需要使用 JdbcTemplate 但我不知道如何使用它。

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但是我没有找到 spring-jdbc 的任何东西

There isn't such thing as JdbcTemplate in Quarkus, nor a support for spring-jdbc . Quarkus 中没有JdbcTemplate之类的东西,也没有对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.所以答案是你不能使用它们,你需要将用法转换为 Spring 数据(或带有 Panache 的 HIbernate),或者注入一个 DataSource object 并直接使用它。

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.由于Class.forName用法,本机编译也需要替换日志记录。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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