首页 > 编程语言 > 详细

Spring Boot 学习

时间:2017-09-27 19:35:07      阅读:259      评论:0      收藏:0      [点我收藏+]

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 学习

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!