Spring Boot使我们更容易去创建基于Spring的独立和产品级的可以”即时运行“的应用和服务。支持约定大于配置,目的是尽可能快地构建和运行Spring应用。

构建环境

JDK 6+

Maven

 

创建项目

1.使用Maven创建一个普通Maven应用即可。

2.修改pom.xml文件

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

3.创建java文件SampleController.java

package hello;

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class SampleController {

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

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

4.Run As Java Application

相关文章:

  • 2021-08-02
  • 2021-05-28
  • 2021-09-10
  • 2021-04-29
  • 2021-10-04
  • 2021-11-29
  • 2021-11-14
猜你喜欢
  • 2021-08-02
  • 2021-09-13
  • 2021-04-08
  • 2021-05-25
  • 2021-12-14
  • 2021-04-24
相关资源
相似解决方案