web-dev-qa-db-fra.com

Maven: artefact manquant org.springframework: spring: jar: 4.2.6

J'ai un projet Web dynamique dans SpringToolSuite. Il est converti en un projet Maven. 

Je reçois le problème: 

Mising artefact org.springframework: spring.jar: 4.2.6

J'ai déjà essayé de nettoyer, de reconstruire et d'exécuter le projet. Il donne: 

Erreur de lecture du fichier C:\Utilisateurs\jublikon.m2\référentiel\org\springframework\printemps\4.2.6\spring-4.2.6.jar C:\Utilisateurs\jublikon.m2\repository\org\springframework\spring\4.2.6\spring-4.2.6.jar (Le système ne peut pas trouver le fichier spécifié)

Je ne comprends pas pourquoi il demande des fichiers jar alors que j'utilise Maven?

pom.xml

    <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.Apache.org/POM/4.0.0 http://maven.Apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.Apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>HelloWeb</groupId>
  <artifactId>HelloWeb</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.Apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.Apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\src\main\Java</sourceDirectory>
    <scriptSourceDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\src\test\Java</testSourceDirectory>
    <outputDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\target\classes</outputDirectory>
    <testOutputDirectory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target</directory>
    <finalName>HelloWeb-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-Assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-war</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <warSourceDirectory>WebContent</warSourceDirectory>
              <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.Apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.Apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.Apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>C:\Users\jublikon\Development\Spring\Projects\HelloWeb\target\site</outputDirectory>
  </reporting>
</project>

J'ai déjà vu ce post mais de toute façon je ne suis pas capable de résoudre mon problème. 

 enter image description here

Quand j'exécute 

mVN propre installer

dans le répertoire racine du projet, je reçois: 

>mvn clean install
[INFO] Scanning for projects...
Downloading: https://repo.maven.Apache.org/maven2/org/springframework/spring-framework-bom/$%7Bspring.version%7D/spring-framework-bom-$%7Bspring.version%7D.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact org.springframework:spring-framework-bom:pom:${spring.version} in central (https://repo.maven.Apache.org/maven2) @ line 29, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-context:jar is missing. @ line 40, column 17
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-core:jar is missing. @ line 44, column 17
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-web:jar is missing. @ line 48, column 17
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-webmvc:jar is missing. @ line 52, column 17
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-aspects:jar is missing. @ line 56, column 17
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project HelloWeb:HelloWeb:0.0.1-SNAPSHOT (C:\Users\jublikon\Development\Spring\Projects\HelloWeb\pom.xml) has 6 errors
[ERROR]     Non-resolvable import POM: Could not find artifact org.springframework:spring-framework-bom:pom:${spring.version} in central (https://repo.maven.Apache.org/maven2) @ line 29, column 21 -> [Help 2]
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-context:jar is missing. @ line 40, column 17
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-core:jar is missing. @ line 44, column 17
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-web:jar is missing. @ line 48, column 17
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-webmvc:jar is missing. @ line 52, column 17
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-aspects:jar is missing. @ line 56, column 17
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.Apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.Apache.org/confluence/display/MAVEN/UnresolvableModelException

J'ai également vérifié mes paramètres de proxy. Le fournisseur actif dans Eclipse est défini sur 'natif' et je ne suis pas connecté via un proxy

Dans l'annuaire 

~/.m2/settings.xml

main is org.Apache.maven.cli.MavenCli from plexus.core

set maven.home default ${user.home}/m2

[plexus.core]
optionally ${maven.home}/lib/ext/*.jar
load       ${maven.home}/lib/*.jar
load       ${maven.home}/conf/logging
3
jublikon

Je suis à peu près sûr qu'il n'y a pas d'artefact appelé "printemps"

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>           <!-- *** spring doesn't *** exist  -->
    <version>4.2.6</version>
</dependency>

En fonction des composants Spring dont vous avez besoin, vous devez inclure ces dépendances:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.2.6.RELEASE</version>
    </dependency>

Dans mon projet Spring, j'inclus les artefacts Spring via une nomenclature:

<properties>
    <spring.version>4.2.6.RELEASE</spring.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${spring.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
    </dependency>
<!-- more -->
</dependencies>
6
JimHawkins

Ce qui a bien fonctionné pour moi, c’est que j’ai téléchargé les fichiers jar de mvnrepository. Je les ai ajoutés à partir du chemin de construction, puis j’ai fait une nouvelle installation compile dans Maven build, puis validé le projet puis mis à jour le projet. 

0
Utkarsh Singh

Maven télécharge par défaut les dépendances requises dans votre référentiel local afin qu'elles puissent être consultées plus rapidement. Peut-être que la dépendance est soit corrompue, soit supprimée de votre disque local? Avez-vous vérifié que C:\Users\jublikon.m2\repository\org\springframework\spring\4.2.6\spring-4.2.6.jar existe réellement et qu'il s'agit d'un fichier jar de printemps valide?

0
Nadir