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

Spring Boot 学习

时间:2017-09-27 21:00:15      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:string   tap   color   ram   static   pre   plugins   oid   nts   

pom

  • 继承父pom
    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>1.5.2.RELEASE</version>
    </parent>
  • 依赖
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
  • 插件
  <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

 SpringBootApplication

@SpringBootApplication
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }
    
}

 RestController

@RestController
@RequestMapping("/demo")
public class DemoController {

    @RequestMapping("/hello")
    String home() {
        return "Hello World!";
    }
    
}

 注意

SpringBootApplication默认扫描当前包下的RestController。自定义扫描目录时使用ComponentScan扫描指定的包。

 github

https://github.com/darrenkeng/springboot

Spring Boot 学习

标签:string   tap   color   ram   static   pre   plugins   oid   nts   

原文地址:http://www.cnblogs.com/darrenkeng/p/7601637.html

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