2017-11-18 126 views
0

我的项目在Spring中遇到问题。首先,我无法在服务器上运行它,但是在再次下载所有资源后,它就开始了。ComponentScan和import org.springframework.context.annotation.ComponentScan无法解析为类型

但现在我有一些进口弹簧在可看不到 例如:

import org.springframework.context.annotation.ComponentScan can not be resolved as a type. 

,并正因为如此休眠的autwired值

@ComponentScan can not be resolved as a type. 

也没有创造我的数据库表(我想所以)

另外两个配置类有一些错误:

类型Spring4Initializer的层次结构是不一致的 SpringSecurityInitializer

public class Spring4Initializer extends AbstractAnnotationConfigDispatcherServletInitializer { 

    @Override 
    protected Class<?>[] getRootConfigClasses() { 
     return new Class[] { Spring4Configuration.class }; 
    } 

    @Override 
    protected Class<?>[] getServletConfigClasses() { 
     return null; 
    } 

    @Override 
    protected String[] getServletMappings() { 
     return new String[] { "/" }; 
    } 

    @Override 
    protected Filter[] getServletFilters() { 
     CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); 
     characterEncodingFilter.setEncoding("UTF-8"); 
     characterEncodingFilter.setForceEncoding(true); 
     return new Filter[] { characterEncodingFilter }; 
    } 
} 

SpringSecurityInitializer在该行 多个标记 - 类型org.springframework.web.WebApplicationInitializer不能得到解决。它是间接地从 所需的.class文件

import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; 

public class SpringSecurityInitializer extends AbstractSecurityWebApplicationInitializer { 

} 

引用我已经试过的Maven干净Maven构建

[WARNING] 
[WARNING] Some problems were encountered while building the effective model for pl.dmcs:eschool:war:1.0.0-BUILD-SNAPSHOT 
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework:spring-context:jar -> version ${org.springframework-version} vs 4.3.7.RELEASE @ line 74, column 17 
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.fasterxml.jackson.core:jackson-databind:jar -> version 2.8.8 vs 2.8.3 @ line 157, column 15 
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: javax.servlet:servlet-api:jar -> version ${servlet-api-version} vs 2.5 @ line 254, column 15 
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework:spring-context:jar -> version ${org.springframework-version} vs 3.0.5.RELEASE @ line 271, column 14 
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. 
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. 
[WARNING] 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building E-School 1.0.0-BUILD-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ eschool --- 
[INFO] Deleting C:\Users\Piotr\Desktop\E-School\target 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 

有谁知道我应该怎么做它,使休眠工作? 在大纲树中我的函数GetHibernateProperites()被标记为红色

回答

0

您是否在您的maven依赖中包含了spring-context?我认为你错过了依赖。

+0

我做到了。但仍然不起作用。 –

+0

我可以看到你的pom文件吗?你正在使用mvn clean install命令吗? –

+0

http://www.wklejto.pl/310782 –