springboot

官方文档解释:

SpringBoot在建立生产中的独立程序上非常简便、只需要一些简便的配置就能运行起来。大致有如下特点:

  1. 创建独立的Spring applications
  2. 能够使用内嵌的Tomcat, Jetty or Undertow,不需要部署war
  3. 提供starter pom来简化maven配置
  4. 自动配置Spring
  5. 提供一些生产环境的特性,比如metrics, health checks and externalized configuration
  6. 绝对没有代码生成和XML配置要求
快速开始:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.4.1.RELEASE</version>

</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>springboot-1</artifactId>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

<version>1.4.1.RELEASE</version>

</plugin>

</plugins>

</build>

</project>



上面是maven配置,接下来需要配置整个程序的入口,AppApplication

@SpringBootApplication

public class AppApplication {

public static void main(String[] args) throws Exception {

SpringApplication.run(AppApplication.class, args);

}}


下面写了一个简易的controller,只要运行main方法或者插件,就能够正常访问了。这块需要注意,controller跟AppApplication放在一个包下面, 

@RestController

public class IndexController {

@GetMapping("/index")

public ResponseEntity helloWord() {

return ResponseEntity.ok("hello word");

}}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值