午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

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

瀏覽:97日期: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
相關文章:
主站蜘蛛池模板: 日本午夜精品 | 欧美黄色免费 | 一区二区免费 | 爆操欧美美女 | 999久久久久久 | 丁香激情网 | 黄色精品网站 | 亚洲成人免费看 | 一级黄色片视频 | 亚洲综合天堂 | 亚洲成人国产 | 极品盗摄国产盗摄合集 | 欧美日韩亚洲视频 | 色交网站| www色小姐com | 97久久久久久 | 免费av网站在线看 | 中文字幕免费高 | 亚洲影视精品 | 国产夫妻自拍av | 成人羞羞网站 | 精品久久久久久久久久久aⅴ | 亚洲欧美日韩中文在线 | 男人的天堂毛片 | 三级色网| 国产又黄又猛又粗又爽 | 黄色一级大片在线免费看产 | 国产影视av| 91免费高清 | 婷婷视频在线播放 | 国产不卡网 | 激情宗合 | 日韩黄色片网站 | 麻豆影视av | 欧美日韩91 | 亚洲国产一区二区三区 | 丁香六月色婷婷 | 欧美成人免费在线视频 | 国产成人在线精品 | 911香蕉| 少妇亚洲 |