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

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

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

瀏覽:50日期: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)文章:
主站蜘蛛池模板: 欧美色影院 | 久久青青操 | 欧美国产日韩精品 | 91亚洲国产成人久久精品麻豆 | 欧美一区| 我要操网站 | 日韩亚洲在线 | 精品视频一区二区三区 | 亚洲精品午夜精品 | 亚洲天堂免费 | 久久亚洲天堂 | 少妇视频网站 | 国产精品成人免费一区久久羞羞 | 日本在线观看一区 | 国产伦精品 | 久久人人视频 | 欧美色图在线视频 | 精品一区二区三区免费看 | 免费美女视频 | 4虎最新网址 | 亚洲理论片 | 精品久久一区 | 黄色免费大片 | √8天堂资源地址中文在线 av网址在线免费观看 | 超碰com| 日本视频免费 | 一级片黄色片 | 蜜臀久久99精品久久久久宅男 | 日本欧美久久久久免费播放网 | 黄色影院在线观看 | 免费看的黄色片 | 中文字幕免费在线 | 91亚洲精品在线 | 91精品亚洲 | av在线小说| 国产一区二区三区免费 | 在线免费观看黄 | 亚洲天堂男人 | 精品久久久久久一区二区里番 | 国产成人毛片 | 久久久一区二区 |