久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

使用springboot暴露oracle數(shù)據(jù)接口的問題

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

新建一個Spring Initializr項目

使用springboot暴露oracle數(shù)據(jù)接口的問題

使用springboot暴露oracle數(shù)據(jù)接口的問題

使用springboot暴露oracle數(shù)據(jù)接口的問題

使用springboot暴露oracle數(shù)據(jù)接口的問題

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

原來的:

使用springboot暴露oracle數(shù)據(jù)接口的問題

現(xiàn)在的:

<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.創(chuàng)建實例類——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; }}

創(chuàng)建接口類——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);}

創(chuàng)建服務類——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); }}

創(chuàng)建控制層類——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'即可看到想要的結(jié)果。

到此這篇關(guān)于使用springboot暴露oracle數(shù)據(jù)接口的文章就介紹到這了,更多相關(guān)springboot oracle數(shù)據(jù)接口內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 涩涩视频网站在线观看 | 亚洲毛片在线观看 | 成人在线精品视频 | 成人精品一区二区三区 | 国产视频中文字幕 | 97色在线视频 | 日韩成人tv | 成人免费一区二区三区视频网站 | 成人精品视频在线观看 | 成人免费视频网址 | 亚洲一区二区免费 | 激情综合五月 | 久久久久久久国产精品 | 国产美女网站 | 中文字幕日韩欧美 | 色婷网 | 精品黄网 | 伊人激情影院 | 午夜在线小视频 | 久久久久久久久久久久久av | 中文字幕亚洲欧美精品一区四区 | 91在线视频福利 | 日韩中文字幕一区二区高清99 | 黄色一级毛片 | 亚洲wu码| 在线欧美日韩 | 亚洲精品成人av | 国产一级特黄毛片在线毛片 | 夏同学福利网 | 精品乱码一区二区 | 午夜精品久久久久久99热软件 | 欧美久久成人 | 91精品一区二区三区久久久久久 | 在线成人免费 | 日韩欧美在线观看一区二区三区 | 亚洲免费在线观看视频 | 国产精品毛片一区二区在线看 | 99热婷婷 | 国内外成人在线视频 | 成人精品一区二区 | 欧美日韩三级 |