Spring mvc Spring Maven应用程序上的Spring注释错误
通过引用创建应用程序 成功保存Pom.xml,所有JAR都显示在EclipseDependence管理上 但是Annotations@Controller在服务和控制器类中无法识别、@Service、@Resource 域类Annotations@Entity等完全被识别和保存 当我第一次配置maven和eclipse时,这个问题还没有出现 在一周的间隔之后,我面临着这个问题 在@guido建议之后 我添加了这个人工制品Spring mvc Spring Maven应用程序上的Spring注释错误,spring-mvc,maven-3,m2eclipse,Spring Mvc,Maven 3,M2eclipse,通过引用创建应用程序 成功保存Pom.xml,所有JAR都显示在EclipseDependence管理上 但是Annotations@Controller在服务和控制器类中无法识别、@Service、@Resource 域类Annotations@Entity等完全被识别和保存 当我第一次配置maven和eclipse时,这个问题还没有出现 在一周的间隔之后,我面临着这个问题 在@guido建议之后 我添加了这个人工制品 <dependency> <groupId>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.5.RELEASE</version>
<scope>compile</scope>
</dependency>
尽管如此,eclipse仍然无法识别@Service
既然,@Resource来自javax.annotation.Resource,我不明白为什么它不出现在eclipse中
好心的建议 我通常为我的spring mvc simple webapp做的是包括以下内容: 这段代码非常基本,如果您不想使用Jackson mapper,它是可以使用的,但是如果您想使用@ResponseBook,它非常有用
<properties>
<spring.version>3.0.6.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.6.4</slf4j.version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<!-- TEST -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- Web / Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Jackson JSON Mapper -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies>
关于spring mvc依赖项的信息非常丰富的链接:您的意思是eclipse会用错误标记注释出现的情况吗?或者spring scanner在启动时找不到您的组件?是的。如果pom.xml中包含spring上下文依赖项,eclipse将使用errorcheck标记注释出现的情况