Maven Related

本文详细介绍了如何使用Eclipse安装并配置Maven环境,包括下载Maven库、使用JDK而非JRE、设置setting.xml文件以正确连接远程仓库,并解决在更新版本时遇到的认证问题。通过将maven-compiler-plugin的版本从2.3.2更改为3.1,成功解决了项目构建失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. Install m2Eclipse

要使用下面这个link.

http://download.eclipse.org/technology/m2e/releases

 

apache-maven-3.2.3\lib\maven-model-builder-3.2.3.jar\org\apache\maven\model\pom-4.0.0.xml

  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

 

2. Maven 需要使用JDK,不能使用JRE.

 

3. setting.xml 中 server 元素的 id 必须与 POM 中需要谁的 repository 元素的 id 完全一致。正是此 id 将认证信息与仓库配置联系在一起。

settings.xml
  <servers>
    <server>
      <id>central</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
  </servers>
  
pom-4.0.0
<project>
  <modelVersion>4.0.0</modelVersion>

  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
</project>

 

4. Change version from 2.3.2 to 3.1, then problem sloved.

DescriptionResourcePathLocationType

Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from https://hostname:8081/nexus/service/local/repositories/mavencentral/content was cached in the local repository, resolution will not be reattempted until the update interval of dsnexus-central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to dsnexus-central (https://hostname:8081/nexus/service/local/repositories/mavencentral/content): Access denied to https://hostname:8081/nexus/service/local/repositories/mavencentral/content/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.pom. Error code 401, Unauthorizedpom.xml/MavenTest2line 1Maven Configuration Problem

 

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
 
### Spring AI Maven Project Setup and Dependencies For setting up a Maven project that integrates the Spring framework with artificial intelligence (AI), one must consider both the foundational elements of Spring as well as libraries or frameworks suitable for implementing AI functionalities. Below is an example `pom.xml` configuration tailored to this purpose, incorporating some common dependencies used in conjunction with Spring: ```xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- Define your group ID, artifact ID, version here --> <dependencies> <!-- Core Spring Boot Starter --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>${spring.version}</version> </dependency> <!-- Web support including RESTful endpoints --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>${spring.version}</version> </dependency> <!-- For security purposes within applications --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> <version>${spring.version}</version> </dependency> <!-- TensorFlow Java API for machine learning tasks --> <dependency> <groupId>org.tensorflow</groupId> <artifactId>tensorflow-core-platform</artifactId> <version>0.4.0</version> </dependency> <!-- Deeplearning4j library for deep learning models --> <dependency> <groupId>org.deeplearning4j</groupId> <artifactId>deeplearning4j-core</artifactId> <version>1.0.0-beta7</version> </dependency> <!-- Apache Commons Math Library which can be useful for various mathematical operations required by ML algorithms --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> <version>3.6.1</version> </dependency> <!-- Add other necessary dependencies based on specific requirements such as database connectivity etc.--> </dependencies> <!-- Plugin configurations go here --> </project> ``` This setup includes core components from Spring along with selected tools aimed at facilitating work related to AI development[^1]. Note how TensorFlow's Java bindings are included alongside DeepLearning4J; these two options provide different approaches towards building intelligent systems depending upon whether symbolic computation graphs (`TensorFlow`) or more direct neural network construction (`DeepLearning4J`) better suit the application scenario.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值