第一个SpringBoot

第一个SpringBoot应用

在这里我选择的开发工具是IntelliJ IDEA  企业版。

在开发前,你需要把环境都装好,Maven,JDK。

按照下面的图片步骤,即可建好一个helloword项目了。

 
勾选中web选项的web

 
这三个目录和文件没什么用,你可以删除。 
第一次建springBoot项目可能需要时间有点久,别急,在下载jar包呢。

新建一个类: 

package cn.chenhaoxiang;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; /** * Created with IntelliJ IDEA. * User: xxx * Date: xxxx/xx/xx. * Time: 下午 xx:xx. * Explain: */ @RestController public class HelloController { @RequestMapping(value = "/hello",method = RequestMethod.GET) public String say() { return "Hello Spring Boot!"; } }

启动方式

1. IDEA直接启动
2. CMD, 切换到项目路径下 启动 : 1. mvn spring-boot run
        2. mvn install -> 切换至target目录下 java -jar ***-0.0.1-SNAPSHOT.jar

猜你喜欢

转载自www.cnblogs.com/Zhouwl/p/9176973.html