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层
@Repository
public interface MedicineMapper extends BaseMapper<Medicine>{
@Select("select HH,PM,BM,CD,DWBH from yw_kck where HH=#{HH}")
Medicine selectOne(String HH);
}
url:
http://localhost:8080/getOne?HH=80004
Controller层接收参数:
@RestController
public class MedicineController {
@Autowired
private MedicineService medicineService;
@RequestMapping("/getOne")
public Medicine getOne( String HH){
return medicineService.getOne(HH);
}
}
文章来源地址https://uudwc.com/A/GdEbD
文章来源:https://uudwc.com/A/GdEbD