springboot+oracle项目搭建
springboot项目搭建
步骤:
idea创建项目
修改pom文件
-
添加web依赖,
-
添加mybatis,oracle依赖
配置application.properties
-
添加数据源信息
此处要去本地服务参看oracle版本型号,orcl 我的比较老xe
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:xe spring.datasource.password=fanli spring.datasource.username=fanli spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
mysql与oracle数据源区别:oracle不用配置数据库名,oracle要设置
-
添加mybatis配置mapper文件路径
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.fanli.oracle_demo.pojo
搭建三层开发模式
controller层
@RestController
@RequestMapping("/staff")
public class StaffController {
@Autowired
private SatffService service;
@GetMapping("/selectAll/{rule}")
public Result selectAll(@PathVariable("rule") String rule){
List<Staff> staff = service.selectAll(rule);
System.out.println(staff);
Result result = new Result(200, "查询成功",staff);
System.out.println(result);
return result;
}}
mapper层
mapper接口
@Mapper
public interface StaffMapper {