配置文件的处理操作,pom.xml
4.0.0
org.example
com.atwanle
3.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
2.2.4.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-maven-plugin
main方法的使用创建处理
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class helloWorld {
public static void main(String[] args)
{
//启动spring主方法
SpringApplication.run(helloWorld.class,args);
}
}
创建一个控制器进行web的页面相应 操作
package wenle.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController
{
@RequestMapping("/hello")
@ResponseBody
public String hello()
{
return "hello world!";
}
}
如果运行的时候端口被占用的话,创建一个配置文件,配置以下其他的端口进行处理。
运行结果
