书接上回
手把手教你用maven创建springboot项目(开发环境为vscode)_weixin_48456383的博客-CSDN博客
我们来正式创建一个简单的项目工程
这个页面还记得吧,不记得的去翻上面的链接,我们从这里出发(只要这一步,前面的那些generate啥的咱也不要了)。把这个zip文件下下来。
解压到你的空Java工程中去,如下所示
老规矩,pom.xml中它还是没有junit,在dependencies里给他加上去
去修改DemoApplication.java
改成如下
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}
长这样:
然后你去springboot根目录去运行
mvn spring-boot:run
等一会儿,不出意外你应该是这个页面
那这就运行成功了!
点击这个url应该就能看到hello world了。
http://localhost:8080/hello
到这里,创建spring boot项目就差不多了!



