博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springboot 详解 (二) crud
阅读量:7055 次
发布时间:2019-06-28

本文共 4707 字,大约阅读时间需要 15 分钟。

 ----------------------------------------------------------------------------------------------------------------

                                            

                                                

                                            

                                       

                                           

             

    

 

----------------------------------------------------------------------------------------------------------------

 

 

 

 

package com.curiousby.cn.controller;import javax.annotation.Resource;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import com.curiousby.cn.one.entity.User;import com.curiousby.cn.service.UserService;@Controller@RequestMapping(value="/web/users")public class UserController {       @Resource    UserService userService;            @ResponseBody    @RequestMapping(value="/{userId}", method=RequestMethod.GET)    public User  getUserById(@PathVariable int userId){                return  userService .findById(userId);     }}

 

@Transactional@Servicepublic class UserService {    @Resource    UserDao userDao;            public User  findById(int userId){        return userDao.findById(userId);    }}

 

@Transactionalpublic interface  UserDao extends CrudRepository
{ //crud User findById(int id);}

 

4.0.0
com.curiousby.cn
SpringBootWebDemo
war
0.0.1-SNAPSHOT
SpringBootWebDemo Maven Webapp
http://maven.apache.org
spring-snapshots
http://repo.spring.io/libs-snapshot
spring-snapshots
http://repo.spring.io/libs-snapshot
org.springframework.boot
spring-boot-starter-parent
1.3.1.RELEASE
UTF-8
1.7
org.springframework.boot
spring-boot-starter-redis
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
provided
org.apache.tomcat.embed
tomcat-embed-jasper
provided
javax.servlet
jstl
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-data-jpa
runtime
mysql
mysql-connector-java
runtime
com.google.code.gson
gson
SpringBootWebDemo
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
1.7
1.7
org.apache.maven.plugins
maven-surefire-plugin
false

 

 

spring.datasource.url=jdbc:mysql://localhost:3306/databasespring.datasource.username=rootspring.datasource.password=rootspring.datasource.driverClassName=com.mysql.jdbc.Driverspring.jpa.database=MYSQLspring.jpa.show-sql=truespring.jpa.hibernate.ddl-auto=updatespring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategyspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

 
 
 谢谢您的赞助,我会做的更好!

转载地址:http://ozmol.baihongyu.com/

你可能感兴趣的文章
Java util包中常用的类和方法
查看>>
[R] 之 管理工作空间函数
查看>>
将windows目录共享到linux
查看>>
计算机是如何启动的
查看>>
Python的raw_input语句包含中文,在Windows环境CMD中显示乱码的解决方法
查看>>
HIbernate学习笔记3 之 缓存和 对象的三种状态
查看>>
2015.3.12Arinc424 Tools中SiniArincCls.csParserFile(string sFile)函数正则表达式理解
查看>>
angularjs探秘<三> 控制器controller及angular项目结构
查看>>
列表的常用操作符和BIF
查看>>
opencv里面CV_32FC1家族
查看>>
在VS2015中用C++创建DLL并用C#调用且同时实现对DLL的调试
查看>>
JavaScript操作DOM的那些坑
查看>>
Acdream Path 动态规划
查看>>
手机版开发框架集合
查看>>
Memcache的客户端连接系列(二) Python
查看>>
shell 环境变量
查看>>
安装xampp二三事
查看>>
2019-04-09 SpringBoot+Druid+MyBatis+Atomikos 的多数据源配置
查看>>
分解质因数
查看>>
字符型图片验证码识别完整过程及Python实现
查看>>