前言
跟前端篇一样,现在记录一下后台应用端开发环境的搭建,针对的是java环境,现在分享给大家。
操作
1、下载和安装Java
下载地址
JDK19和17
JDK8和11
下载dmg安装即可,接着查询安装java的位置
➜ ~ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
19.0.2 (arm64) "Oracle Corporation" - "Java SE 19.0.2" /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
找到java安装位置 之后,现在我们来编辑.bash_profile文件
,添加java环境
#java home
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
保存完之后,别忘了source ~/.bash_profile
2、下载和安装Maven
点击官网下载地址下载
下载之后解压到你想要保存的地方即可。
保存完之后,配置一下环境变量,再次编辑~/.bash_profile
#java home
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
# maven home
M3_HOME=/Users/justinzhang/Library/Maven/apache-maven-3.9.0
export PATH=$JAVA_HOME/bin:$M3_HOME/bin:$PATH:
这样就完成了Java和Maven的安装,查看Java和Maven的版本
➜ ~ java --version
java 19.0.2 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
➜ ~ mvn -v
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /Users/justinzhang/Library/Maven/apache-maven-3.9.0
Java version: 19.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
3、配置maven setting.xml文件
先找到maven安装路径,我的路径是
~/Library/apache-maven-3.5.0/conf/settings.xml
找到之后编辑setting.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>mirror</id>
<mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf>
<name>mirror</name>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<servers>
<server>
<id>rdc-releases</id>
<username>xxx</username>
<password>xxx(H</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>xxx</username>
<password>xxx(H</password>
</server>
</servers>
<profiles>
<profile>
<id>rdc</id>
<properties>
<altReleaseDeploymentRepository>
rdc-releases::default::https://packages.aliyun.com/maven/repository/2113702-release-6l40oS/
</altReleaseDeploymentRepository>
<altSnapshotDeploymentRepository>
rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2113702-snapshot-zW0Kdb/
</altSnapshotDeploymentRepository>
</properties>
<repositories>
<repository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-releases</id>
<url>https://packages.aliyun.com/maven/repository/2113702-release-6l40oS/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://packages.aliyun.com/maven/repository/2113702-snapshot-zW0Kdb/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-releases</id>
<url>https://packages.aliyun.com/maven/repository/2113702-release-6l40oS/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-snapshots</id>
<url>https://packages.aliyun.com/maven/repository/2113702-snapshot-zW0Kdb/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>rdc</activeProfile>
</activeProfiles>
</settings>
这样就配置好了Maven。
Idea配置
现在我们到idea中配置Java和Maven环境
总结
1、如果你使用的是压缩包安装方式安装Java,只要放到指定目录即可,然后配置Java环境,而使用dmg安装方式安装后的Java目录,必须使用/usr/libexec/java_home -V
才能获取取。
2、安装好maven之后记得配置setting.xml文件。
3、Idea如果报Java相关错,看看是不是没有设置java版本
引用
lombok与jdk版本对应关系 - 爱码网
解决 Maven ‘parent.relativePath‘ of POM
MacOS下安装及配置Maven
超详细的Java安装教程(Mac 版)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。