初学总结SpringBoot项目在mac上环境搭建和运行

mac一定要安装上homebrew,这个玩意在mac上搭建环境贼拉好用,打开终端安装国内镜像的

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

1. brew安装maven

brew install maven

2.修改maven国内镜像
mac上homebrew安装路径一般 macintosh hd,里面的隐藏文件opt中,使用 cmd+shift+. 快捷键显示出隐藏文件,找到路径
/opt/homebrew/cellar/maven/3.9.9/libexec/conf/setting.xml,使用记事本打开,在 标签下添加镜像设置,并保存

<mirror>
	<id>aliyun</id>
	<mirrorOf>*</mirrorOf>
	<url>https://maven.aliyun.com/repository/public</url>
</mirror>

3.brew安装mysql brew安装的mysql本地配置默认用户名是root,且没有密码,这很重要,通过brew info mysql查看

brew install mysql

在这里插入图片描述

4.启动mysql

mysql.service start
mysql -u root -p
//一般无密码,无需输入直接回车,mysql就启动了

下图就是sql本地服务启动成功:
在这里插入图片描述

5.vscode创建springboot项目, 安装必须的vscode插件
chinese language pack for visual… 汉化插件根据个人需求安装
extension for java (microsoft)
maven for java (microsoft)
project manager for java (microsoft)
spring boot dashboard (microsoft)
spring initializr java support (microsoft)
spring boot tools (vmware)
spring boot extension pack (vmware)
mysql (weijian chen)
xml(red hat)

6.创建springboot项目
输入框输入 >spring 选择spring initializr
选择springboot版本 第一个即可 3.4.2
选择语言 java/kotlin
输入包名 com.example.demo
输入项目名,也是打包输出的默认名字 demo
打包输出选择 jar
jdk版本选择 18,没有的随便选一个,后面再改,
选择依赖:先选个spring boot devtool, lombok, 或者不选,项目编译好后再加
选择保存位置
vscode弹出提示框点击 open 打开项目,
构建失败不要紧,配置一下:
pom.xm

<properties>
		<java.version>1.8</java.version>
		<mybatisplus-spring-boot-starter.version>1.0.5</mybatisplus-spring-boot-starter.version>
        <mybatisplus.version>2.3.1</mybatisplus.version>
        <poi.version>3.9</poi.version>
</properties>

<repositories>
	<repository>
		<id>aliyun</id>
			<url>https://maven.aliyun.com/repository/public</url>
		</repository>
        <repository>
            <id>central</id>
            <url>https://repo1.maven.org/maven2</url>
        </repository>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<releases>
				<enabled>false</enabled>
			</releases>
		</repository>
	</repositories>

<dependencies>
	    <dependency>
	        <groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-starter-actuator<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值