DemoApplication.java:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class DemoApplication {

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

@RequestMapping("/")
String index(){
return "这是第一个Spring Boot工程!";
}

}

 

有3种方式运行

1、直接运行主程序

2、根目录下面mvn spring-boot:run

3、根目录下面mvn install打成jar包

java -jar demo-0.0.1-SNAPSHOT.jar

 

访问

http://localhost:8080/

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!