> 技术文档 > 人工智能_大模型098_TRAE_AI开发工具_RuoyiSpringCloudPlus微服务开发配置_配置使用本地Maven_配置jdk版本为1.8---人工智能工作笔记0243_trae 配置maven

人工智能_大模型098_TRAE_AI开发工具_RuoyiSpringCloudPlus微服务开发配置_配置使用本地Maven_配置jdk版本为1.8---人工智能工作笔记0243_trae 配置maven

   trae这个开发工具由于有原生支持Ai,确实是好用,但是对于熟悉了idea开发的伙伴来说,如果

多次使用trae,打开自己之前的项目无法启动,那么就可能放弃使用trae了.

   很多原来使用idea的项目,如果使用trae打开以后,发现启动都会有报错的现象.

原因是,以前很多微服务项目使用的jdk是jdk1.8,但是现在trae默认内置了jdk21,所以要修改jdk的默认版本为1.8.

另外,由于trae自带的Maven,会自动从阿里云上下载对应的依赖,所以,有可能导致下载的依赖不全,那么

就会导致微服务无法启动,编译不通过.

看看如果解决,首先需要安装对应的扩展:

可以看到安装这个插件

对java的支持

然后是对maven的支持插件

 

然后是对springboot的支持插件

然后再去安装SVN插件

然后再去安装maven 这里,可以设置maven

使用,自己本地的maven也是可以的,从上面这里设置

其实就是在扩展上,右键点击设置就可以

然后再来看还可以指定

~/.m2/settings.xml 这个文件

这个文件中指定了,maven的镜像,以及maven放在本地什么位置

因为maven一般放在不是c盘中,尤其是依赖,有时候太大了.就可以修改这个文件

然后来看这个配置文件,点击就可以打开

可以看到,就是上面这个配置,配置本地的就可以了

看看本地的 配置文件 可以看到

 <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository /path/to/local/repo --> D:\\Java\\maven\\repository <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true true --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false false -->   <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. com.your.plugins -->    <!-- proxy | Specification for one proxy, to be used in connecting to the network. |  optional true http proxyuser proxypass proxy.host.net 80 local.net|some.host.com  -->    <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the \'id\' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. |  deploymentRepo repouser repopwd  --> <!-- Another sample, using keys to authenticate.  siteServer /path/to/private/key optional; leave empty if not used.  -->      alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central    alimaven2 aliyun maven2 http://maven.aliyun.com/nexus/content/groups/public/ central     mirrorId central Human Readable Name  https://repo1.maven.org/maven2/    alimaven3 aliyun maven http://central.maven.org/maven3 central    junit junit Address/ http://jcenter.bintray.com/ central  <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. |  mirrorId repositoryId Human Readable Name for this Mirror. http://my.repository.com/repo/path  -->    <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via  | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as \'env-dev\', \'env-test\', \'env-production\', \'user-jdcasey\', \'user-brett\', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id\'s for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.  jdk-1.4  1.4    jdk14 Repository for JDK 1.4 builds http://www.myhost.com/maven/jdk14 default always    --> <!-- | Here is another profile, activated by the system property \'target-env\' with a value of \'dev\', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... |  | org.myco.myplugins | myplugin | |  | ${tomcatPath} |  |  | ... | | NOTE: If you just wanted to inject this configuration whenever someone set \'target-env\' to | anything, you could just leave off the  inside the activation-property. |  env-dev   target-env dev    /path/to/tomcat/instance   -->  <!-- activeProfiles | List of profiles that are active for all builds. |  alwaysActiveProfile anotherAlwaysActiveProfile  -->

这里我把本地的settings.xml文件的内容,放出来了

这个配置还是比较全面的,如果只用阿里云的话,有些jar包,可能没有就导致

下载不到就会出错. 

可以看到这个是本地的仓库Maven的

然后,这里发现一个问题就是,

如果重新打开TRAE会发现,他默认的maven配置的路径

上面这个路径下,又出现,下载的依赖了,说明我们的配置没有生效,那么

这里注意,就可以这样操作

先删除,默认路径下的依赖文件

然后再去,直接把我们的settings.xml文件

覆盖到,他默认的.m2文件夹中的settings.xml

因为我们settings.xml已经指定了,依赖不放到C盘了.所以 把配置文件放在这里就可以了

启动项目以后,可以看到,就不会自动把依赖下载到默认目录,

而是下载到我们指定的目录了.

然后后来发现,编译的时候,使用maven

项目编译不通过,报错,是因为jdk版本导致的,我们找到java的扩展

然后右键去看设置,可以看到在settings.json中

可以看到就是设置在这个地方.

注意这个settings.json文件

然后再来看,我们这个时候,就可以去使用maven

去编译微服务项目了,但是编译的时候,发现编译报错,

是因为jdk版本导致的,我们可以看到,默认他的jdk是21,我们实际用的是1.8

{ \"maven.terminal.customEnv\": [ { \"environmentVariable\": \"JAVA_HOME\", \"value\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\" } ], \"maven.dependency.enableConflictDiagnostics\": true, \"editor.linkedEditing\": true, \"editor.minimap.enabled\": false, \"editor.rulers\": [ { \"column\": 80, \"color\": \"#00FF0010\" }, { \"column\": 100, \"color\": \"#BDB76B15\" }, { \"column\": 120, \"color\": \"#FA807219\" } ], \"editor.unicodeHighlight.includeComments\": true, \"workbench.colorCustomizations\": { \"[Default Dark Modern]\": { \"tab.activeBorderTop\": \"#00FF00\", \"tab.unfocusedActiveBorderTop\": \"#00FF0088\", \"textCodeBlock.background\": \"#00000055\" }, \"editor.wordHighlightStrongBorder\": \"#FF6347\", \"editor.wordHighlightBorder\": \"#FFD700\", \"editor.selectionHighlightBorder\": \"#A9A9A9\" }, \"workbench.editor.revealIfOpen\": true, \"files.eol\": \"\\n\", \"[bat]\": { \"files.eol\": \"\\r\\n\" }, \"emmet.variables\": { \"lang\": \"zh\" }, \"cSpell.diagnosticLevel\": \"Hint\", \"trailing-spaces.backgroundColor\": \"rgba(255,0,0,0.1)\", \"trailing-spaces.includeEmptyLines\": false, \"terminal.integrated.tabs.hideCondition\": \"never\", \"terminal.integrated.enablePersistentSessions\": false, \"java.compile.nullAnalysis.mode\": \"automatic\", \"java.configuration.detectJdksAtStart\": false, \"java.configuration.updateBuildConfiguration\": \"automatic\", \"java.debug.settings.hotCodeReplace\": \"auto\", \"java.dependency.packagePresentation\": \"hierarchical\", \"java.maxConcurrentBuilds\": 6, \"java.sources.organizeImports.staticStarThreshold\": 1, \"java.configuration.runtimes\": [ { \"name\": \"JavaSE-1.8\", \"path\": \"C:\\\\java\\\\jdk\" }, { \"name\": \"JavaSE-11\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\" }, { \"name\": \"JavaSE-17\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\" }, { \"name\": \"JavaSE-21\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\" }, { \"name\": \"JavaSE-24\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\", \"default\": true } ], \"terminal.integrated.profiles.windows\": { \"JavaSE-1.8 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\java\\\\jdk\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\java\\\\jdk\" }, \"path\": \"cmd\" }, \"JavaSE-11 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\" }, \"path\": \"cmd\" }, \"JavaSE-17 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\" }, \"path\": \"cmd\" }, \"JavaSE-21 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\\\\bin;${env:PATH}\", \"JAVA_TOOL_OPTIONS\": \"-Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\" }, \"path\": \"cmd\", \"args\": [ \"/k\", \"chcp\", \"65001\" ] }, \"JavaSE-24\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\\\\bin;${env:PATH}\", \"JAVA_TOOL_OPTIONS\": \"-Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\" }, \"path\": \"cmd\", \"args\": [ \"/k\", \"chcp\", \"65001\" ] } }, \"terminal.integrated.automationProfile.windows\": { \"path\": \"cmd\" }, \"java.test.config\": { \"vmArgs\": [ \"-Dstdout.encoding=UTF-8\", \"-Dstderr.encoding=UTF-8\" ] }, \"maven.excludedFolders\": [ \"**/.*\", \"**/node_modules\", \"**/target\", \"**/bin\", \"**/archetype-resources\" ], \"maven.executable.preferMavenWrapper\": true, \"maven.settingsFile\": \"D:\\\\Java\\\\settings.xml\", \"java.import.gradle.home\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\gradle\\\\latest\", \"maven.terminal.favorites\": [ ], \"terminal.integrated.defaultProfile.windows\": \"JavaSE-24\", \"maven.executable.path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\maven\\\\latest\\\\bin\\\\mvn\", \"terminal.integrated.env.windows\": { \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\", \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\\\\bin;${env:PATH}\" }, \"java.import.gradle.java.home\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\", \"java.jdt.ls.java.home\": \"C:\\\\Java\\\\jdk\"}

这里我直接给出一个,可以复制过去使用

其中,C:\\\\Java\\\\jdk 

就是本地的jdk1.8的位置. 下面还有一个修改好了的,可以把

下面那个修改好的这个配置文件,复制过去用. 

可以看到默认,他这里在JavaSE-24这里,有个default:true

这个我们把他修改到JavaSE-18里面去.

可以看到,我们需要用编辑器打开,

找到对应的,可以看到上面这个几个地方需要修改 

这里也需要修改

这里也需要修改.

我们可以把他之前的,配置文件备份一下,然后

这个settings.json文件的位置在这里.

{ \"maven.terminal.customEnv\": [ { \"environmentVariable\": \"JAVA_HOME\", \"value\": \"C:\\\\java\\\\jdk\" } ], \"maven.dependency.enableConflictDiagnostics\": true, \"editor.linkedEditing\": true, \"editor.minimap.enabled\": false, \"editor.rulers\": [ { \"column\": 80, \"color\": \"#00FF0010\" }, { \"column\": 100, \"color\": \"#BDB76B15\" }, { \"column\": 120, \"color\": \"#FA807219\" } ], \"editor.unicodeHighlight.includeComments\": true, \"workbench.colorCustomizations\": { \"[Default Dark Modern]\": { \"tab.activeBorderTop\": \"#00FF00\", \"tab.unfocusedActiveBorderTop\": \"#00FF0088\", \"textCodeBlock.background\": \"#00000055\" }, \"editor.wordHighlightStrongBorder\": \"#FF6347\", \"editor.wordHighlightBorder\": \"#FFD700\", \"editor.selectionHighlightBorder\": \"#A9A9A9\" }, \"workbench.editor.revealIfOpen\": true, \"files.eol\": \"\\n\", \"[bat]\": { \"files.eol\": \"\\r\\n\" }, \"emmet.variables\": { \"lang\": \"zh\" }, \"cSpell.diagnosticLevel\": \"Hint\", \"trailing-spaces.backgroundColor\": \"rgba(255,0,0,0.1)\", \"trailing-spaces.includeEmptyLines\": false, \"terminal.integrated.tabs.hideCondition\": \"never\", \"terminal.integrated.enablePersistentSessions\": false, \"java.compile.nullAnalysis.mode\": \"automatic\", \"java.configuration.detectJdksAtStart\": false, \"java.configuration.updateBuildConfiguration\": \"automatic\", \"java.debug.settings.hotCodeReplace\": \"auto\", \"java.dependency.packagePresentation\": \"hierarchical\", \"java.maxConcurrentBuilds\": 6, \"java.sources.organizeImports.staticStarThreshold\": 1, \"java.configuration.runtimes\": [ { \"name\": \"JavaSE-1.8\", \"path\": \"C:\\\\java\\\\jdk\", \"default\": true }, { \"name\": \"JavaSE-11\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\" }, { \"name\": \"JavaSE-17\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\" }, { \"name\": \"JavaSE-21\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\" }, { \"name\": \"JavaSE-24\", \"path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\" } ], \"terminal.integrated.profiles.windows\": { \"JavaSE-1.8 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\java\\\\jdk\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\java\\\\jdk\" }, \"path\": \"cmd\" }, \"JavaSE-11 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\11\" }, \"path\": \"cmd\" }, \"JavaSE-17 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\\\\bin;${env:PATH}\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\17\" }, \"path\": \"cmd\" }, \"JavaSE-21 LTS\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\\\\bin;${env:PATH}\", \"JAVA_TOOL_OPTIONS\": \"-Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\21\" }, \"path\": \"cmd\", \"args\": [ \"/k\", \"chcp\", \"65001\" ] }, \"JavaSE-24\": { \"overrideName\": true, \"env\": { \"PATH\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\\\\bin;${env:PATH}\", \"JAVA_TOOL_OPTIONS\": \"-Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8\", \"JAVA_HOME\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\java\\\\latest\" }, \"path\": \"cmd\", \"args\": [ \"/k\", \"chcp\", \"65001\" ] } }, \"terminal.integrated.automationProfile.windows\": { \"path\": \"cmd\" }, \"java.test.config\": { \"vmArgs\": [ \"-Dstdout.encoding=UTF-8\", \"-Dstderr.encoding=UTF-8\" ] }, \"maven.excludedFolders\": [ \"**/.*\", \"**/node_modules\", \"**/target\", \"**/bin\", \"**/archetype-resources\" ], \"maven.executable.preferMavenWrapper\": true, \"maven.settingsFile\": \"D:\\\\Java\\\\settings.xml\", \"java.import.gradle.home\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\gradle\\\\latest\", \"maven.terminal.favorites\": [ ], \"terminal.integrated.defaultProfile.windows\": \"JavaSE-1.8 LTS\", \"maven.executable.path\": \"C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Trae CN\\\\User\\\\globalStorage\\\\pleiades.java-extension-pack-jdk\\\\maven\\\\latest\\\\bin\\\\mvn\", \"terminal.integrated.env.windows\": { \"JAVA_HOME\": \"C:\\\\Java\\\\jdk\", \"PATH\": \"C:\\\\Java\\\\jdk\\\\bin;${env:PATH}\" }, \"java.import.gradle.java.home\": \"C:\\\\Java\\\\jdk\", \"java.jdt.ls.java.home\": \"C:\\\\Java\\\\jdk\"}

上面这个是修改后的可以直接拿过去用的配置文件

但是要记得,修改成自己本地的jdk的目录 

注意,编辑配置文件以后,一定要重启TRAE才会生效.

然后 重启以后去TRAE的terminal中执行java -version

测试一下看看,他的java版本是否是1.8了.

然后就可以去正常编译项目了,可以看到.

编译成功了.