mac下spring环境搭建 -- 重学程序第一天
mac下安装idea:
这里就不写了,idea的安装比较简单
mac下安装maven:
配置环境变量
1)打开终端输入命令 vim ~/.bash_profile (编辑环境变量配置文件)
2)按下i,进入编辑模式
3)在环境变量文件中加上如下的配置
export MAVEN_HOME=/Users/darcy/Documents/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
PS:(可以将文件直接拖拽至终端内文件路径便可显示出来)
4)输入 :wq退出并保存当前文件
5)输入 source .bash_profile,按下Enter键使bash_profile生效。
6)输入 mvn -v,结果如下图所示即表明配置成功
mac下idea中使用native terminal:
spring initializr的使用:
1 package geektime.spring.hello.hellospring; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 import org.springframework.web.bind.annotation.RequestMapping; 6 import org.springframework.web.bind.annotation.RestController; 7 8 @SpringBootApplication 9 @RestController 10 public class HelloSpringApplication { 11 12 public static void main(String[] args) { 13 SpringApplication.run(HelloSpringApplication.class, args); 14 } 15 16 @RequestMapping("/hello") 17 public String hello() { 18 return "hello spring"; 19 20 } 21 }
环境搭建完毕