Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package org.springframework.stereotype does not exist

Tags:

maven

i get package org.springframework.stereotype error as im running mvn install. even in .m2 folder there is that package.

error showing me tho this line of code :

import org.springframework.stereotype.Service;

dependencies are :

<springVersion>4.1.1.RELEASE</springVersion>
<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${springVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${springVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${springVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${springVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${springVersion}</version>
      </dependency>

is there something i missed ?

UPDATE

here is full lines of error i get :

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project mynewProject: Compilation failure: Compilation failure:
[ERROR] /C:/mynewProject/src/main/java/com/web/server/domain/service/WebServiceImpl.java:[17,38] package org.springframework.stereotype does not exist
[ERROR] /C:/mynewProject/src/main/java/com/web/server/domain/service/WebServiceImpl.java:[25,2] cannot find symbol
like image 530
Lauris01 Avatar asked Feb 13 '15 14:02

Lauris01


3 Answers

I got similar issues when on my standalone java program when running on java 8 and spring 4.x.

For some reason, i don't see spring-context in the referenced Jars of the project. It should be automatically referenced by maven, but I did not see that happening.

Solution : I added the spring-context dependency manually in the pom.xml and my error is fixed.

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.5.RELEASE</version>
</dependency>
like image 77
Karthik Cherala Avatar answered Dec 22 '22 00:12

Karthik Cherala


I needed to change the scope-tag to 'compile' instead of 'runtime', and the error went away.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
    <scope>compile</scope>

like image 39
Morten Nørgaard Avatar answered Dec 21 '22 23:12

Morten Nørgaard


All the dependencies should be within

<dependencies>
    ...
</dependencies>

... or your code will continue throwing that error.

like image 43
Rajesh734 Avatar answered Dec 21 '22 23:12

Rajesh734