spring boot CLI 下载安装 配置环境变量
cmd输入
第一个web应用
@SpringBootApplication //@EnableEurekaClient @RestController public class MicroserviceProviderUserApplication { @GetMapping("/hello/{name}") public String hello(@PathVariable String name){ System.out.println(name+" welcome . My is microservice provider user"); return name+" welcome . I'm microservice provider user"; } public static void main(String[] args) { SpringApplication.run(MicroserviceProviderUserApplication.class, args); } }
server.port=8081
启动后浏览器请求http://localhost:8081/hello/zhu
若是用命令行启动mvn spring-boot:run
1 No plugin found for prefix ‘spring-boot’ in the current project
解决办法:pom.xml加入
<repositories> <repository> <id>spring-releases</id> <url>https://repo.spring.io/libs-release</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-releases</id> <url>https://repo.spring.io/libs-release</url> </pluginRepository> </pluginRepositories>然后命令行进入包含该pom.xml的目录下启动
2 Unable to find a single main class
解决办法:一个jar只能有一个main方法