springboot搭建教程
来源:互联网 发布:淘宝工业生产许可证 编辑:程序博客网 时间:2024/06/11 21:13
之前一直在搜索教程搭ssh环境,结果一大堆配置文件搞的我很烦。特别是集成hibernate的时候。。遂室友荐springboot搭建之,结果不到10分钟就搭完了,分享一下心得。
目录结构
package com.angry.controller;/** * Created by Angry on 2017/9/26. */import com.angry.domain.User;import com.angry.repository.UserRepository;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.bind.annotation.RequestMapping;@RestControllerpublic class helloController { @Autowired UserRepository userRepository; @RequestMapping("/") public String index() { System.out.println(userRepository.getClass()); return "succeed"; } @RequestMapping("/save") public boolean testsave() { User user =new User(); //user.setId(3); user.setName("test"); user.setPassword("123"); user.setDefaultAddress("111"); user.setRole(2); userRepository.save(user); return true; }}controller
package com.angry.domain;import java.sql.Timestamp;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;import javax.persistence.Table;/** * Created by Angry on 2017/9/27. */@Entity@Table(name = "user")public class User { @Id @GeneratedValue private int id; private String name; private String password; private String defaultAddress; private String defaultPhone; private String mail; private Integer money; private Timestamp regTime; private int role; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getDefaultAddress() { return defaultAddress; } public void setDefaultAddress(String defaultAddress) { this.defaultAddress = defaultAddress; } public String getDefaultPhone() { return defaultPhone; } public void setDefaultPhone(String defaultPhone) { this.defaultPhone = defaultPhone; } public String getMail() { return mail; } public void setMail(String mail) { this.mail = mail; } public Integer getMoney() { return money; } public void setMoney(Integer money) { this.money = money; } public Timestamp getRegTime() { return regTime; } public void setRegTime(Timestamp regTime) { this.regTime = regTime; } public int getRole() { return role; } public void setRole(int role) { this.role = role; }}实体类
阅读全文
1 0
- springboot搭建教程
- 【SpringBoot教程一】:简单搭建
- 【SpringBoot教程一】:简单搭建
- springboot手把手教程实战-环境搭建-001
- 《Grande教程系列》四.使用gradle搭建SpringBoot项目
- 【SpringBoot教程二】:RESTfull API简单项目的快速搭建
- 【超详细图文教程】用SpringBoot+Maven搭建SSM框架
- SpringBoot搭建
- springboot搭建
- springboot搭建
- springboot搭建
- SpringBoot12-springboot-springboot快速搭建
- SpringBoot非官方教程 | 第二十六篇: sprinboot整合elk,搭建实时日志平台
- SpringBoot非官方教程 | 第二十六篇: sprinboot整合elk,搭建实时日志平台
- SpringBoot 快速搭建
- springboot多环境搭建
- Springboot--工程搭建
- SpringBoot快速搭建笔记
- STM32F103和STM32F105在串口初始化的区别
- J2EE规范-入门学习
- synchronized的4种用法
- 使用kafka作为springcloud bus的消息总线,以及如何自定义总线事件
- java简单入门程序--扫雷游戏
- springboot搭建教程
- SQL语句,更新字段,新值是旧值的一部分
- 关于java web项目并发锁的理解
- 微软基础类MFC
- 用户态和内核态
- 父元素设置min-height子元素设置100%问题
- JavaScript实现一个简单数据结构栈
- iCarousel 1.8.1版本简介(官方文档翻译)
- Eclipse_4.6.3(neon)新建工程的注意事项