Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring安全配置不适用于<;tx:注释驱动>;标签。给定编译错误_Java_Spring_Spring Mvc_Spring Security - Fatal编程技术网

Java Spring安全配置不适用于<;tx:注释驱动>;标签。给定编译错误

Java Spring安全配置不适用于<;tx:注释驱动>;标签。给定编译错误,java,spring,spring-mvc,spring-security,Java,Spring,Spring Mvc,Spring Security,我收到以下编译错误:: cvc复杂类型.2.4.c:匹配的通配符是严格的,但找不到元素“tx:annotation-driven”的声明 我的dispatcher servlet xml是::: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="h

我收到以下编译错误::

cvc复杂类型.2.4.c:匹配的通配符是严格的,但找不到元素“tx:annotation-driven”的声明

我的dispatcher servlet xml是:::

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:tx="http://www.springframework.org/schema/tx"  
        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/tx  
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <context:property-placeholder location="classpath:resources/database.properties" />
        <context:component-scan base-package="com.suva.*" />
         <tx:annotation-driven transaction-manager="hibernateTransactionManager"/>  

        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
                <value>/WEB-INF/pages/</value>
            </property>
            <property name="suffix">
                <value>.jsp</value>
            </property>
        </bean>
<bean id="hibernateTransactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />    </bean>



     <bean id="dataSource"  
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
      <property name="driverClassName" value="${database.driver}" />  
      <property name="url" value="${database.url}" />  
      <property name="username" value="${database.user}" />  
      <property name="password" value="${database.password}" />  
     </bean>  



     <bean id="sessionFactory"  
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
      <property name="dataSource" ref="dataSource" />  
      <property name="hibernateProperties">  
       <props>  
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
        <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
        <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>      
       </props>  
      </property>  
     </bean>  

    </beans>
我正在使用以下罐子:

commons-logging-1.1.1.jar
jstl-1.2.jar
org.springframework.aop-3.0.1.RELEASE-A.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.aspects-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context.support-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.jar
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEASE-A.jar
org.springframework.web.servlet-3.0.1.RELEASE-A.jar
org.springframework.web-3.0.1.RELEASE-A.jar
spring-security-config-3.2.3.RELEASE.jar
spring-security-core-3.2.1.RELEASE.jar
spring-security-web-3.2.3.RELEASE.jar
spring-tx-3.0.1.RELEASE.jar
我的类路径中有spring-tx-3.0jar和其他spring配置jar


请帮帮我,伙计们,我完全被这搞糊涂了..挣扎了两周..找不到任何解决方案。

你在GitHub上有代码吗?嗨@Geo,谢谢你的回复..我在GitHub上没有代码。但我可以给你这里的代码。实际上,我有一个简单的spring安全登录应用程序,我将通过hibernate与db集成。上次你解决了我关于这个简单应用程序的错误。所以我想你已经有了代码。如果你没有,请告诉我我会上传到这里。嗨,上次我在另一台计算机上,所以我没有你的代码。继续并上传到某个地方,我会在有机会的时候下载它,并尝试弄清楚发生了什么。好的,我只是在这个问题线程上更新。请指出我错在哪里。你在这里发布的都是你的代码?那些罐子怎么样?你用的是哪一种?
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
                           http://www.springframework.org/schema/beans/spring-beans.xsd  
                           http://www.springframework.org/schema/security  
                           http://www.springframework.org/schema/security/spring-security-3.2.xsd">

    <security:http auto-config="true">
        <security:intercept-url pattern="/admin/**"
            access="ROLE_USER" />
    </security:http>

    <security:authentication-manager>
        <security:authentication-provider>
            <!-- <security:user-service>
                <security:user name="user" password="pass"
                    authorities="ROLE_USER" />
                <security:user name="suva" password="123" authorities="ROLE_USER" />

            </security:user-service>-->

            <security:jdbc-user-service data-source-ref="dataSource"    
      users-by-username-query="select username, password, active from users where username=?"   

  />  

        </security:authentication-provider>
    </security:authentication-manager>

</beans>
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController {

    @RequestMapping(value = { "/", "/welcome**" }, method = RequestMethod.GET)
    public ModelAndView welcomePage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title", "Spring Security Hello World");
        model.addObject("message", "This is welcome page!");
        model.setViewName("hello");
        return model;

    }

    @RequestMapping(value = "/admin**", method = RequestMethod.GET)
    public ModelAndView adminPage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title", "Spring Security Hello World");
        model.addObject("message", "This is protected page!");
        model.setViewName("admin");

        return model;

    }

}
commons-logging-1.1.1.jar
jstl-1.2.jar
org.springframework.aop-3.0.1.RELEASE-A.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.aspects-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context.support-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.jar
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEASE-A.jar
org.springframework.web.servlet-3.0.1.RELEASE-A.jar
org.springframework.web-3.0.1.RELEASE-A.jar
spring-security-config-3.2.3.RELEASE.jar
spring-security-core-3.2.1.RELEASE.jar
spring-security-web-3.2.3.RELEASE.jar
spring-tx-3.0.1.RELEASE.jar