0


Springboot连接Oracle数据库

pom文件

<dependencies><!--用的是2.3.12.RELEASE版本--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.2</version></dependency><!-- https://mvnrepository.com/artifact/com.oracle.database.nls/orai18n --><!--oracle 必备 , 用于处理oracle中文乱码 , 可以删除试试代码运行情况,--><dependency><groupId>com.oracle.database.nls</groupId><artifactId>orai18n</artifactId><version>19.7.0.0</version></dependency><!--<dependency>--><!--<groupId>com.baomidou</groupId>--><!--<artifactId>mybatis-plus-generator</artifactId>--><!--<version>${mybatis-plus-generator.version}</version>--><!--<scope>test</scope>--><!--</dependency>--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>com.oracle.database.jdbc</groupId><artifactId>ojdbc8</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

application.yml文件

server:
  port: 8080
spring:
  datasource:
    driverClassName: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@192.168.2.13:1521:orcl #orcl为sid
    username: cjk
    password: admin#6966
mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.example.demo.entity
  configuration:
    map-underscore-to-camel-case: true

mapper层

@RepositorypublicinterfaceMedicineMapperextendsBaseMapper<Medicine>{@Select("select HH,PM,BM,CD,DWBH from yw_kck where HH=#{HH}")MedicineselectOne(String HH);}

url:

http://localhost:8080/getOne?HH=80004

Controller层接收参数:

@RestControllerpublicclassMedicineController{@AutowiredprivateMedicineService medicineService;@RequestMapping("/getOne")publicMedicinegetOne(String HH){return  medicineService.getOne(HH);}}

本文转载自: https://blog.csdn.net/qq_53906512/article/details/131508859
版权归原作者 凹凸曼说我是怪兽y 所有, 如有侵权,请联系我们删除。

“Springboot连接Oracle数据库”的评论:

还没有评论