Spring Boot使用现有的JDBC连接进行连接

Spring boot根据application.properties中的配置提供了它自己的数据库连接。但是在这里,我有一个服务,为我提供了javax.sql.Connection类型的对象。

src / main / resources / application.properties

    componentDidmount(){
      document.getElementById("ID_NAME").innerHTML = <Text>hello world</Text>
    }
    render() {
      return (
        <Text id="ID_NAME"></Text>
      )
    }

这是存储库的代码

server.port=9090
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

控制器代码

package com.example.springbootdemo.repositories;
import org.springframework.data.repository.CrudRepository;
import com.example.springbootdemo.model.Box;
public interface BoxRepository extends CrudRepository<Box,Long> {
}

在这里,当我调用JPA信息库的保存功能时,它会使用db对象保存该对象,而db对象是使用自己的一些包装器来计算的。

但是我必须使用一个jar,它可以给我数据库连接。代替在src / main / resources / application.properties中进行配置,我必须使用从此jar返回的连接对象。现在,我需要覆盖spring boot内部使用的连接对象。我无法弄清楚该如何做。

xxingx 回答:Spring Boot使用现有的JDBC连接进行连接

您具有以下路径:src // main // resoruces // application.properties

在这里您需要配置

本文链接:https://www.f2er.com/3166703.html

大家都在问