jublikon jublikon - 6 months ago 129
Java Question

missing artifact org.springframework:spring:jar:4.2.6

I have a dynamic web project in SpringToolSuite.
It is converted into a Maven project.

I am getting the issue:


Mising artifact org.springframework:spring.jar:4.2.6


I already tried to clean, rebuild and run the project.
It gives:


Error reading file
C:\Users\jublikon.m2\repository\org\springframework\spring\4.2.6\spring-4.2.6.jar
C:\Users\jublikon.m2\repository\org\springframework\spring\4.2.6\spring-4.2.6.jar
(The system cannot find the specified file)


I do not understand why it is asking for jar files while I am using Maven?

pom.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>
<groupId>HelloWeb</groupId>
<artifactId>HelloWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.6</version>
</dependency>
</dependencies>
</project>


I have already seen this post but somehow I am not able to solve my problem.

enter image description here

Answer

I'm quite sure there is no artifact called "spring"

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

Depending on the Spring components you need, you should basically include these dependencies:

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

In my Spring project, I include the Spring artifacts via a BOM (Bill of Materials):

<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>