Spring servlet配置文件抛出异常

时间:2013-05-09 11:24:56

标签: java spring-mvc

我得到以下异常:

Build path is incomplete. Cannot find class file for com/hexgen/core/IHexGenDictionaryBased

这是我得到上述例外的一行:

<context:component-scan base-package="com.hexgen.api.facade" />

这是完整的XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:sec="http://www.springframework.org/schema/security"
    xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <sec:global-method-security pre-post-annotations="enabled"
                                secured-annotations="enabled"
                                authentication-manager-ref="authenticationManager"
                                proxy-target-class="true">
        <sec:expression-handler ref="expressionHandler"/>
    </sec:global-method-security>

    <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
        <property name="permissionEvaluator" ref="hexgenPermissionEvaluator" />
    </bean>

    <bean id="hexgenPermissionEvaluator" class="com.hexgen.api.facade.security.HexGenPermissionEvaluator"/>

    <context:component-scan base-package="com.hexgen.api.facade" />
    <mvc:annotation-driven />
    <context:annotation-config />
</beans>

任何人都可以解释我要做些什么来解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

我认为您需要让组件扫描查看api和核心的公共包。

<context:component-scan base-package="com.hexgen.api.facade" />更改为<context:component-scan base-package="com.hexgen" />,它应该选择找不到的核心类。

答案 1 :(得分:1)

您需要确保com/hexgen/core/IHexGenDictionaryBased类(或其.class文件)所在的位置需要位于构建路径(或类路径)上。例如,如果它在其他一些hexgen-core.jar中,请确保将其添加到构建路径(使用Eclipse)或类路径(使用-cp参数)。

如果某个其他项目目录中的文件然后将其/src添加为Spring项目的源目录,则所有core类将自动出现在类路径中。