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

   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盘中,尤其是依赖,有时候太大了.就可以修改这个文件

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

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

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

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<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">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>D:\Java\maven\repository</localRepository>

  <!-- 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
  <interactiveMode>true</interactiveMode>
  -->

  <!-- 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
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- 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.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- 阿里云镜像 -->
    <mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    <mirrorOf>central</mirrorOf>
    </mirror>
	
	 <!-- 阿里云镜像 -->
	
	 <mirror>  
      <id>alimaven2</id>  
      <name>aliyun maven2</name>  
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
      <mirrorOf>central</mirrorOf>          
    </mirror>

    <!-- maven官方镜像 -->
    <mirror>
    <id>mirrorId</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name </name>
    <url>https://repo1.maven.org/maven2/</url>
    </mirror>

    <!-- 又一个镜像 -->
    <mirror>
    <id>alimaven3</id>
    <name>aliyun maven</name>
    <url>http://central.maven.org/maven3</url>
    <mirrorOf>central</mirrorOf>
    </mirror>


    <!-- junit镜像地址 -->
    <mirror>
    <id>junit</id>
    <name>junit Address/</name>
    <url>http://jcenter.bintray.com/</url>
    <mirrorOf>central</mirrorOf>
    </mirror>
      <!-- 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.
      |
      <mirror>
        <id>mirrorId</id>
        <mirrorOf>repositoryId</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://my.repository.com/repo/path</url>
      </mirror>
      -->
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- 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 <activatedProfiles/>
     | 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.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | 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:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

这里我把本地的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了.

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

编译成功了.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'readFileContentController' defined in file [D:\maven_use\lingxi-lhc\lingxi-ai-extend\lingxi-ai-comparison\target\classes\com\luxsan\controller\ReadFileContentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'readFileContentService' defined in file [D:\maven_use\lingxi-lhc\lingxi-ai-extend\lingxi-ai-comparison\target\classes\com\luxsan\service\ReadFileContentService.class]: no opencv_java455 in java.library.path: C:\Java\jdk-17\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Java\jdk-17\bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Java\jdk1.8.0_152\bin;C:\Windows\System32\OpenSSH\;D:\node\node_global\node_module;%NODE_HOME%\node_global;%NODE_HOME%\node_cache;node_global\node_modules;node_global;node_cache\node_modules;node_cache;node_ global\node_modules;C:\Program Files\CorpLink\current\module\epm\x64;D:\work\nvm;C:\Program Files\nodejs;C:\Java\jdk-17\bin;C:\Java\jdk-17\jre\bin;D:\Git\Git\cmd;D:\apache-maven-3.9.5\bin;D:\node\;C:\Program Files\Tesseract-OCR;D:\work\OpenCV\opencv\build\java\x64;C:\Users\Administrator\AppData\Local\Programs\Python\Launcher\;d:\work\Trae CN\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;D:\work\nvm;C:\Program Files\nodejs;D:\work\IntelliJ IDEA 2024.3\bin;D:\node\node_global;C:\Users\Administrator\AppData\Local\Programs\Python\Python313;;.
最新发布
07-26
<think>好的,我现在需要帮助用户解决如何配置和运行TraeJDK的问题。用户提到了字节的AI开发工具Trae,但我不太确定这个工具的具体情况。首先,我应该先确认Trae的相关信息,可能需要查阅已有的引用或者资料。 根据用户提供的引用[2],里面提到在Trae中运行Spring Boot项目的步骤,包括通过快捷键打开用户设置JSON文件。这可能意味着Trae是基于某种编辑器或IDE开发的,比如VS Code,因为ctrl+shift+p是VS Code的命令面板快捷键。因此,推测Trae可能是基于VS Code的插件或扩展工具。 接下来,用户需要配置JDK并运行Trae配置JDK通常需要先安装JDK,并设置环境变量。然后,在Trae中指定JDK的路径。根据引用[1],Maven项目的结构以及pom.xml的配置可能相关,因为用户可能需要配置项目的JDK版本和依赖。 可能的步骤包括: 1. 安装JDK配置环境变量。 2.Trae中设置JDK路径,可能需要通过用户设置JSON文件添加配置项。 3. 配置项目的pom.xml文件,确保JDK版本正确。 4. 使用Trae的运行命令或功能启动项目。 需要验证这些步骤是否正确,尤其是Trae如何识别JDK路径。可能需要参考引用[2]中的步骤,打开用户设置JSON文件后,添加类似"java.home": "JDK安装路径"的配置。此外,确保Maven配置正确,引用[1]中的项目结构可能需要符合Trae的要求。 另外,用户的问题可能涉及到项目依赖管理和构建工具,因此需要检查pom.xml中的JDK版本设置,比如使用maven-compiler-plugin指定源和目标版本。例如: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> </configuration> </plugin> </plugins> </build> ``` 最后,运行项目可能需要通过Trae的界面或命令执行mvn spring-boot:run,或者在JSON配置中设置启动命令。需要确保所有步骤中的路径和版本号正确,避免环境变量问题导致的错误。</think>### 如何配置和运行Trae使用JDK #### 1. **安装并配置JDK** - **步骤说明**: - 下载与项目匹配的JDK版本(例如JDK 11)[^1]。 - 安装完成后,配置系统环境变量: - 添加`JAVA_HOME`变量,值为JDK安装路径(例如`C:\Program Files\Java\jdk-11.0.15`)。 - 将`%JAVA_HOME%\bin`添加到`Path`变量中。 - 验证安装:命令行输入`java -version`,确认版本信息。 #### 2. **在Trae中设置JDK路径** - **步骤说明**: - 打开Trae工具,使用快捷键`Ctrl+Shift+P`调出命令面板,输入`Preferences: Open User Settings (JSON)`[^2]。 - 在JSON配置文件中添加JDK路径: ```json { "java.home": "C:/Program Files/Java/jdk-11.0.15" } ``` - 保存后重启Trae,确保配置生效。 #### 3. **配置Maven项目兼容JDK** - **步骤说明**: - 在项目的`pom.xml`中,通过`maven-compiler-plugin`指定JDK版本: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> ``` - 保存文件,Trae会自动加载Maven依赖[^1]。 #### 4. **运行Spring Boot项目** - **步骤说明**: -Trae中打开项目根目录,确保结构符合标准: ``` src |-main |-java (源代码) |-resources(配置文件) |-test |-java (测试代码) |-resources pom.xml ``` - 使用Trae内置的Maven命令或终端输入: ```bash mvn spring-boot:run ``` - 若需调试,可通过Trae的调试功能启动---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

添柴程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值