日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

超级无敌狂爆龙战士

發(fā)布時(shí)間:2024/1/8 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 超级无敌狂爆龙战士 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在這里插入代碼片 `###POM文件 <?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 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><packaging>war</packaging><name>springboot_build</name><groupId>com.jishi</groupId><artifactId>springboot_build</artifactId><version>1.0-SNAPSHOT</version><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId></exclude></excludes></configuration></plugin></plugins></build><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.5</version></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.5.5</version></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>2.5.5</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.41</version></dependency><dependency><groupId>org.webjars</groupId><artifactId>jquery</artifactId><version>3.5.1</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.20</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency></dependencies></project>###![在這里插入圖片描述](https://img-blog.csdnimg.cn/297ca83800ed4bc7900c23e99454e06e.png#pic_center)```java 在這里插入代碼片 ###bean包下 的Userpackage com.jishi.boot.bean;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.springframework.stereotype.Component;@ToString @AllArgsConstructor @NoArgsConstructor @Data @Component public class User {private Integer id;private String username;private String password; }###controler下的UserController package com.jishi.boot.controller;import com.jishi.boot.bean.User; import com.jishi.boot.service.UserService; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource;@RequestMapping("/user") @Controller public class UserController {@ResourceUserService userService;@ResponseBody@RequestMapping("/login")public String hello(User user){if (userService.login(user) != null){System.out.println("打印一下該查詢的值"+userService.login(user));return "登入成功";}else {return "登入失敗";}} }` ###service包下的接口UserService package com.jishi.boot.service;import com.jishi.boot.bean.User; import org.springframework.stereotype.Service;@Service public interface UserService {public Integer login (User user); }###service包下的UserServiceImp package com.jishi.boot.service.Imp;import com.jishi.boot.bean.User; import com.jishi.boot.dao.UserDao; import com.jishi.boot.service.UserService; import org.springframework.stereotype.Service;import javax.annotation.Resource;@Service public class UserServiceImp implements UserService {@ResourceUserDao userDao;@Overridepublic Integer login(User user) {return userDao.login(user);} }###dao包下的UserDao package com.jishi.boot.dao;import com.jishi.boot.bean.User; import org.apache.ibatis.annotations.Mapper;public interface UserDao {/*** 登入* @param user* @return*/public Integer login (User user); }###mapper包下的userDao.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.jishi.boot.dao.UserDao"><select id="login" resultType="java.lang.Integer" >SELECT *FROM loginuserWHERE id = #{id} AND username = #{username} AND password = #{password}</select> </mapper>###resources包下的application.yaml spring:datasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/curd?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=falsedriver-class-name: com.mysql.jdbc.Drivermvc:hiddenmethod:filter:enabled: truemybatis:configuration:map-underscore-to-camel-case: truemapper-locations: classpath:mapper/*.xml###與各層級(jí)同層的啟動(dòng)類 package com.jishi.boot;import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;@MapperScan("com.jishi.boot.dao") @SpringBootApplication public class MainApplication {public static void main(String[] args) {SpringApplication.run(MainApplication.class, args);} }###crud的mapperDao。簡單sql直接寫在dao上 package com.example.crud.mapper;import com.example.crud.pojo.User; import org.apache.ibatis.annotations.*;import java.util.List;@Mapper public interface UserMapper {/*** 查詢?nèi)繑?shù)據(jù)*/@Select("select * from user")public List<User> findAll();*** 新增數(shù)據(jù)*/@Insert("insert into user (username, password) values (#{username}, #{password})")public int save(User user);/*** 刪除數(shù)據(jù)*/@Delete("delete from user where id=#{id}")public int delete(int id);/*** 根據(jù)ID查找用戶*/@Select("select * from user where id=#{id}")public User get(int id);/*** 根據(jù)ID更新用戶數(shù)據(jù)*/@Update("update user set username=#{username},password=#{password} where id=#{id}")public int updateById(User user); }

總結(jié)

以上是生活随笔為你收集整理的超级无敌狂爆龙战士的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。