码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Boot 精简笔记

时间:2017-07-16 19:24:23      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:ace   date   put   find   work   tap   http请求   content   interface   

0. Fundamental
  a. @SpringBootApplication
  b. pom.xml
  

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/>
</parent>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

  

1. application.yml (application-dev.yml, application-prod.yml)

    spring:
      profiles:
        active: prod

    server:
        port: 8080
        content-path: /demo

    student:
      name: Peter
      age: 19
      message: My name is ${student.name}, age is ${student.age}


    spring: 
        datasource:
            driver-class-name: com.mysql.jdbc.Driver
            url: jdbc:mysql://127.0.0.1:3306/demo
            username: root
            password: 123465
        jpa:
            hibernate:
                dll-auto: update
            show-sql: true

 

2. 注入设置值
  a. 直接使用单个值:@Value("${student.name}")
  b. 注入配置类:
  @ConfigurationProperties(prefix = "student")
  @Component

3. Controller
  a. @Controller: 处理http请求,返回模板文件名 (旧方式)
  b. @RestController:处理请求,返回json
  @RequestMapping: 配置URL映射
  @GetMapping, @PutMapping, @PostMapping, @DeleteMapping
  @PathVariable, @RequsetParam

4. Spring-Data-Jpa
  a. @Entity
  b. @Id
  c. Interface class Repository (findOne,findAll,findByXXX,save)
  d. @Service, @Transactional

 

Spring Boot 精简笔记

标签:ace   date   put   find   work   tap   http请求   content   interface   

原文地址:http://www.cnblogs.com/pekkle/p/7191239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!