目录
【3】配置环境变量+maven阿里云仓库+idea加载oracle11g驱动
【0】首先看运行效果
【1】基础软件安装,含附件(百度网盘)
名称:基础软件安装
链接:https://pan.baidu.com/s/1IMQkoBJdnBSTJlf7w1wIFg?pwd=kzry
提取码:kzry
(1)java8安装+maven3.3
ps:java8安装包直接无脑下一步就行(默认在C:\Program Files), maven3.3.压缩包解压即可
(2)oracle11g安装
(3)navicat安装
ps:选好目录一直下一步就行了
(4)idea安装+破解
ps:这个就自行安装和破解版,文章很多
【2】navicat连接oracle数据库+创建测试表图片
(1)navicat配置oracle所需oci
oci.dll文件在上面oracle的安装包里面
(2)连接默认的system用户
密码是你刚才安装oracle时候输入的密码,我的是123456
(3)创建一个新的数据库+用户
【3】配置环境变量+maven阿里云仓库+idea加载oracle11g驱动
(1)配置 java+maven环境变量
java系统变量:
新建JAVA_HOME-->C:\Program Files\Java\jdk1.8.0_131
新建CLASSPATH-->.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
Path变量后面增加-->;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
maven系统变量:
新建MAVEN_HOME-->D:\maven3_39
Path变量后面增加-->;%MAVEN_HOME%\bin
测试如下图:
(2)maven配置阿里云仓库地址
setting文件地址在 maven339\conf 下
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
(3)idea加载oracle11g驱动
首先在oracle安装目录找到ojdbc6.jar这个文件
在 oracle11g\product\11.2.0\dbhome_1\jdbc\lib 下
然后打开cmd,输入
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0 -Dpackaging=jar -Dfile=D:\oracle11g\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar
【4】目录+源码附件
pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>DemoFour</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--springboot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--hutool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.2</version>
</dependency>
<!--oracle 11g-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.1.0</version>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.1</version>
</dependency>
<!--mybatis-plus代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.2</version>
</dependency>
<!--knife4j-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.7</version>
</dependency>
<!--satoken-->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot-starter</artifactId>
<version>1.30.0</version>
</dependency>
</dependencies>
<build>
<finalName>DemoFour</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
ItestStudentServiceImpl.java 主要业务文件
/**
* <p>
* 学生表 服务实现类
* </p>
*
* @author xuchenliang
* @since 2022-06-02
*/
@Service
public class ItestStudentServiceImpl extends ServiceImpl<ItestStudentMapper, ItestStudent> implements ItestStudentService {
@Autowired
ItestStudentService itestStudentService;
//查列表+过滤+分页
@Override
public SaResult selectItestStudentList(ItestStudentSelectDto itestStudentSelectDto) {
try {
//构造器
QueryWrapper<ItestStudent> Querywrapper = new QueryWrapper<>();
Querywrapper.lambda()
.eq(StrUtil.isNotEmpty(itestStudentSelectDto.getId()), ItestStudent::getId, itestStudentSelectDto.getId())
.eq(StrUtil.isNotEmpty(itestStudentSelectDto.getStuName()), ItestStudent::getStuName, itestStudentSelectDto.getStuName())
.eq(StrUtil.isNotEmpty(itestStudentSelectDto.getStuAge()), ItestStudent::getStuAge, itestStudentSelectDto.getStuAge())
;
//分页查询
IPage<ItestStudent> page = itestStudentService.page(new Page<>(itestStudentSelectDto.getCurrent(), itestStudentSelectDto.getSize()), Querywrapper);
return SaResult.data(page);
}catch(Exception e){
return SaResult.error();
}
}
//插入+修改
@Override
public SaResult insertOrUpdateItestStudent(ItestStudentInOrUpDto itestStudentInOrUpDto) {
try {
ItestStudent itestStudent= Convert.convert(ItestStudent.class, itestStudentInOrUpDto);
itestStudentService.saveOrUpdate(itestStudent);
return SaResult.ok();
}catch(Exception e){
return SaResult.error();
}
}
//删除+批量删除
@Override
public SaResult deleteItestStudent(ItestStudentDelDto itestStudentDelDto) {
try {
List<String> idList= Arrays.asList(itestStudentDelDto.getId().split(","));
itestStudentService.removeByIds(idList);
return SaResult.ok();
}catch(Exception e){
return SaResult.error();
}
}
}
ItestStudentController.java
/**
* <p>
* 学生表 前端控制器
* </p>
*
* @author xuchenliang
* @since 2022-06-02
*/
@RestController
@RequestMapping("/demoFour/itest-student")
@Api(tags = "学生模块")
public class ItestStudentController {
@Autowired
ItestStudentService itestStudentService;
@PostMapping("/selectItestStudentList")
@ApiOperation(value = "查询列表+过滤")
public SaResult selectItestStudentList(@RequestBody ItestStudentSelectDto itestStudentSelectDto){
return itestStudentService.selectItestStudentList(itestStudentSelectDto);
}
@PostMapping("/insertOrUpdateItestStudent")
@ApiOperation(value = "插入+修改")
public SaResult insertOrUpdateAdrList(@RequestBody ItestStudentInOrUpDto itestStudentInOrUpDto){
return itestStudentService.insertOrUpdateItestStudent(itestStudentInOrUpDto);
}
@PostMapping("/deleteAdrList")
@ApiOperation(value = "删除+批量删除")
public SaResult deleteAdrList(@RequestBody ItestStudentDelDto itestStudentDelDto){
return itestStudentService.deleteItestStudent(itestStudentDelDto);
}
}
名称:项目源码
链接:https://pan.baidu.com/s/1awn7MoRhu7AcFAG2DjJqUQ?pwd=m0go
提取码:m0go
运行项目不报错后,网址输入:
http://localhost:8001/doc.html