Spring Initializr(Web界面方式)
使用Web方式:
要使用Spring Initializr,最直接的办法就是使用浏览器打开https://start.spring.io。
package com.example.spring.hello.hellospring;
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 HelloSpringApplication {
public static void main(String[] args) {
SpringApplication.run(HelloSpringApplication.class, args);
}
@RequestMapping("/hello")
public String hello(){
return "Hello Spring";
}
}
导入到idea 然后执行 访问即可
启动成功,在浏览器输入:http://localhost:8080/hello
可以看到成功返回了Hello Spring
打包命令 mvn clean package -Dmaven.test.skip