- 1. 配置基本环境
- 2. Spring Intializr
- 3. Spring Boot 入门实例
jdk:8u131
maven:3.6.1,远程仓库改成阿里云镜像仓库
idea:2019.1.4,配置maven路径
https://start.spring.io/
上面导入的包缺少aop,手动在pom.xml中加入依赖
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-aopartifactId>
dependency>
解压下载包后用idea打开
3. Spring Boot 入门实例
java 包下新建 controller 包新建 AlphaController 类
@RequestMapping(“/alpha”) 是给这个类提供一个访问名称
sayHello() 给浏览器一个访问的返回方法
@ResponseBody 只返回字符串
package com.psynowcoder.community.community.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/alpha")
public class AlphaController {
@RequestMapping("/hello")
@ResponseBody
public String sayHello() {
return "Hello Spring Boot.";
}
}
在 .properties中修改配置信息
修改访问端口为8088
项目地址/community
server.port=8088
server.servlet.context-path=/community
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)