package org.springframework.stereotype does not exist
Solution 1
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>
Solution 2
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>
Solution 3
All the dependencies should be within
<dependencies>
...
</dependencies>
... or your code will continue throwing that error.
Related videos on Youtube

Comments
-
Lauris01 over 2 years
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
-
DB5 almost 8 yearsCan you include a bit more of the error message? The class
org.springframework.stereotype.Service
is contained in the spring-context dependency, which you have correctly defined. Without more information it is hard to help any further. -
Lauris01 almost 8 yearssee my update. full error message. I dont know what more could i include
-
-
Fatmajk almost 3 yearsSolved it for me! Thanks