av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

使用springboot暴露oracle數據接口的問題

瀏覽:33日期:2023-03-12 17:07:04

新建一個Spring Initializr項目

使用springboot暴露oracle數據接口的問題

使用springboot暴露oracle數據接口的問題

使用springboot暴露oracle數據接口的問題

使用springboot暴露oracle數據接口的問題

2.把pom.xml文件中的oracle依賴換成自己的oracle版本依賴:

原來的:

使用springboot暴露oracle數據接口的問題

現在的:

<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.1.0</version></dependency>

3.編輯application.yml

spring: datasource: driver-class-name: oracle.jdbc.driver.OracleDriver url: jdbc:oracle:thin:@192.168.21.200:1521:orcl username: alisa password: alisa

4.創建實例類——Userinfos.java:

package cn.alisa.myspboracle.entity; import java.util.Date; public class Userinfos { private int userid; private String username; private Date birthyear; private float userhight; public int getUserid() {return userid; } public void setUserid(int userid) {this.userid = userid; } public String getUsername() {return username; } public void setUsername(String username) {this.username = username; } public Date getBirthyear() {return birthyear; } public void setBirthyear(Date birthyear) {this.birthyear = birthyear; } public float getUserhight() {return userhight; } public void setUserhight(float userhight) {this.userhight = userhight; }}

創建接口類——UserinfosDAO.java

package cn.alisa.myspboracle.dao; import cn.alisa.myspboracle.entity.Userinfos;import org.apache.ibatis.annotations.Select; import java.util.List; public interface UserinfosDAO { @Select('select userid,username,birthyear,userhight from userinfos') public List<Userinfos>findAll(); @Select('select userid,username,birthyear,userhight from userinfos where username like ’%${name}%’') public List<Userinfos>findUserSameName(String name);}

創建服務類——UserinfosService.java

package cn.alisa.myspboracle.service; import cn.alisa.myspboracle.dao.UserinfosDAO;import cn.alisa.myspboracle.entity.Userinfos;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service; import java.util.List; @Servicepublic class UserinfosService { @Autowired private UserinfosDAO udao; public List<Userinfos>searchAll(){return udao.findAll(); } public List<Userinfos>sameName(String name){return udao.findUserSameName(name); }}

創建控制層類——InitCtrl.java:

package cn.alisa.myspboracle.ctrl; import cn.alisa.myspboracle.entity.Userinfos;import cn.alisa.myspboracle.service.UserinfosService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestControllerpublic class InitCtrl { @Autowired private UserinfosService userinfosService; @RequestMapping('/all') public List<Userinfos>init(){return userinfosService.searchAll(); } @RequestMapping('/same') public List<Userinfos>same(String name){return userinfosService.sameName(name); }}

編輯MyspboracleApplication.java類:

package cn.alisa.myspboracle; import org.mybatis.spring.annotation.MapperScan;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication@MapperScan('cn.alisa.myspboracle.dao')public class MyspboracleApplication { public static void main(String[] args) { SpringApplication.run(MyspboracleApplication.class, args); } }

運行此類(MyspboracleApplication.java),在瀏覽器中輸入'http://localhost:8080/all'或者'http://localhost:8080/same?name=l'即可看到想要的結果。

到此這篇關于使用springboot暴露oracle數據接口的文章就介紹到這了,更多相關springboot oracle數據接口內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 成人在线一区二区 | 一区二区三区四区免费观看 | 很黄很污的网站 | 天天综合干 | 天天操妹子 | 九色网址 | 日韩中文字幕在线视频 | 精品视频在线免费观看 | 99免费在线视频 | 欧美成人视屏 | 亚洲免费视频在线观看 | 欧美国产中文字幕 | 国产1区2区在线观看 | 欧美a区 | 亚洲成av人片在线观看 | 久久久免费电影 | 日韩电影一区 | 一级大黄色片 | 国产一区2区 | 精品久久久久久久久久久下田 | 一区二区三区亚洲视频 | 亚洲三级在线 | 国产精品视频久久久久 | 国内精品在线视频 | 国产日韩精品一区二区三区 | 亚洲一级视频在线 | 欧美亚洲一区二区三区 | 国产福利视频 | www.成人.com | 亚洲系列第一页 | 一级片在线视频 | 日韩一区二区在线免费观看 | 国产精品久久久久久久久久久久久 | 狠狠干狠狠操 | 中文字幕免费中文 | 国产亚洲一区二区三区 | 中文在线a在线 | 成人片网址| 中文字幕一级 | 精品二区| 国产乱码精品一区二区三区中文 |