<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://127.0.0.1:3306/uunemodb">
</property>
<property name="username" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.fetch_size">100</prop>
<!-- <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> -->
</props>
</property>
<!-- <property name="eventListeners"> -->
<!-- <map> -->
<!-- <entry key="merge"> -->
<!-- <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/> -->
<!-- </entry> -->
<!-- </map> -->
<!-- </property> -->
<property name="packagesToScan">
<list>
<value>com.uunemo.*</value>
</list>
</property>
</bean>
<!-- 声明一个 Hibernate 3 的事务管理器供代理类自动管理事务用 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory" /></property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 激活spring的注解. -->
<context:annotation-config />
<!-- Spring AOP auto-proxy creation (required to support Shiro annotations) -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<!-- 事务控制 -->
<!-- 加入shiro后报错,代理类异常,因此使用aspectj的注解方式 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- <tx:annotation-driven mode="aspectj"></tx:annotation-driven> -->
<!-- 扫描注解组件并且自动的注入spring beans中.
例如,他会扫描@Controller 和@Service下的文件.所以确保此base-package设置正确. -->
<context:component-scan base-package="com.uunemo" />
<context:component-scan base-package="com.uunemo.security" />
<!-- 配置注解驱动的Spring MVC Controller 的编程模型.注:次标签只在 Servlet MVC工作! -->
<mvc:annotation-driven />
<!-- 用注解来实现事务管理 -->
<mvc:resources location="/resources/" mapping="/resources/**"/>
<!-- =========================================================
Shiro Components
========================================================= -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after -->
<!-- the lifecycleBeanProcessor has run: -->
<!-- delete on 04.26 -->
<!-- <bean -->
<!-- class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" -->
<!-- depends-on="lifecycleBeanPostProcessor" /> -->
<!-- <bean -->
<!-- class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> -->
<!-- <property name="securityManager" ref="securityManager" /> -->
<!-- </bean> -->
<!-- Shiro's main business-tier object for web-enabled applications (use
org.apache.shiro.web.mgt.DefaultWebSecurityManager instead when there is
no web environment) -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!-- Single realm app (realm configured next, below). If you have multiple
realms, use the 'realms' property instead. -->
<property name="realm" ref="nemoRealm" />
<!-- Uncomment this next property if you want heterogenous session access
or clusterable/distributable sessions. The default value is 'http' which
uses the Servlet container's HttpSession as the underlying Session implementation.
<property name="sessionMode" value="native"/> -->
</bean>
<!-- Define the Shiro Filter here (as a FactoryBean) instead of directly in web.xml -
web.xml uses the DelegatingFilterProxy to access this bean. This allows us
to wire things with more control as well utilize nice Spring things such as
PropertiesPlaceholderConfigurer and abstract beans or anything else we might need: -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/checkuser"/>
<property name="successUrl" value="/home"/>
<property name="unauthorizedUrl" value="/unauthorized"/>
<!-- The 'filters' property is usually not necessary unless performing an override, which we
want to do here (make authc point to a PassthruAuthenticationFilter instead of the
default FormAuthenticationFilter: -->
<!-- <property name="filters">-->
<!-- <util:map>-->
<!-- <entry key="authc">-->
<!-- <bean class="org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter"/>-->
<!-- </entry>-->
<!-- </util:map>-->
<!-- </property>-->
<!-- <property name="filterChainDefinitions">-->
<!-- <value>-->
<!-- /s/signup = anon-->
<!-- /s/manageUsers = perms[user:manage]-->
<!-- /s/** = authc-->
<!-- </value>-->
<!-- </property>-->
</bean>
</beans>
spring 配置如上
java代码如下所示:
@Resource(name="UserDAO") protected UserDAO userDAO;
报错如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nemoRealm': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'UserDAO' must be of type [com.uunemo.daos.UserDAO], but was actually of type [$Proxy19]
我已经指明了使用基于类的代理 proxy-target-class="true",为何spring还是基于代理来做,求解答
求大神解答
相关推荐
<!--配置连接池--> <bean id="dataSource" class=... <aop:config> <aop:pointcut id="pointcut" expression="execution(* com.itheima.service.impl.*.*(..))"/> <aop:advisor advice-ref="advice" pointcut-ref=
<context:annotation-config></context:annotation-config> <context:component-scan base-package="org.whvcse"></context:component-scan> <tx:annotation-driven transaction-manager="txManager" /> <!-- ...
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <!-- <bean id="dataSource" class="org....
<value>true</value> </constructor-arg> </bean> <!-- ptc windchill的數據庫 --> <bean id="dataSourcePdm" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property ...
<bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <!-- 配置數...
<bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="locations"> <value>classpath:properties/jdbc.properties</value> </property> </bean> ...
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> ...
<aop:config> <aop:pointcut id="serviceOperation" expression="execution(* *..servi1ce*..*(..))"/> <aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/> </aop:config> <!-- 通知配置...
基于XML的声明式AspectJ <aop:config>元素及其子元素如下: 小提示:图中灰色部分标注的元素即为常用的配置元素 XML文件中常用元素的配置方式如下: 基于XML的声明式AspectJ <bean id="myAspect" class=...
<aop:config proxy-target-class="true"/> <tx:annotation-driven transaction-manager="txManager"/> <!-- 采用单数据源事务控制方式,通过注解来定义事务--> <bean id="txManager" class="org.spring...
<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy> xml中要有这句,可以解决子类类报错的问题。 或者去掉这句话,同时去掉public class AccountServiceImpl implements AccountService {...
<prop key="show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/longxian/drp/models/Module.hbm.xml</value> <value>...
</aop:config> spring和struts2的整合 加入整合包 加入struts的必须包 struts整合spring的包 struts2-spring-plugin-2.3.15.3.jar spring整合struts的包 org.springframework.web-3.1.3.RELEASE.jar org.spring...
<tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> //tx标签代表时间传播 <aop:config>//切入 <aop:pointcut id="allServiceMethod" expression="execution(* com.cstp.service.*.*...
</beans><context:annotation-config/> <context:component-scan base-package="com.spring.*"/> 两行为开启spring的注解配置 <aop:aspect id="aspect" ref="logIntercepter"> 引入具体的AOP操作类 <aop:pointcut ...
<bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <!-- 配置數...
<property name="defaultAutoCommit" value="true" /> </bean> <!-- jdbc注入 --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref=...
<aop:config> <!-- 配置切点表达式 --> <aop:pointcut id="pointcut1" expression="execution(public void com.jas.aop.bean.PersonImpl.sayHello())"/> <aop:pointcut id="pointcut2" expression=...
<bean id="cacheProxyFactoryBean" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="interceptorNames"> <list> <value>cacheBeforeAdvice</value> <value>cacheAfterAdvice</...