2017-11-18 128 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 –