我在applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 创建sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>file:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 事务管理器 -->
<bean id="tm" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 2.0事务 -->
<tx:advice id="txadvice" transaction-manager="tm">
<tx:attributes>
<tx:method name="get*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice> <aop:config>
<aop:pointcut id="bizs"
expression="execution(* bo.*.*(..))" />
<aop:advisor advice-ref="txadvice" pointcut-ref="bizs" />
</aop:config>
<!-- bo配置 -->
<bean id="tTreeBo" class="com.web.bo.Home.TTreeBo">
<property name="tTreeDao"> <!--这里报错No setter found for property 'tTreeDao' in class 'com.web.bo.Home.TTreeBo'-->
<ref local="tTreeDao"/>
</property>
<property name="tAuthorityBo"><!--这里报错No setter found for property 'tAuthorityBo' in class 'com.web.bo.Home.TTreeBo'--> <ref local="tAuthorityBo"/>
</property>
</bean>
<bean id="tAuthorityBo" class="com.web.bo.Home.TAuthorityBo">
<property name="tAuthorityDao"> <!--这里报错No setter found for property 'tAuthorityDao' in class 'com.web.bo.Home.TAuthorityBo'--> <ref local="tAuthorityDao"/>
</property>
</bean>
<!-- dao配置 -->
<bean id="tTreeDao" class="com.web.dao.Home.TTreeDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="tAuthorityDao" class="com.web.dao.Home.TAuthorityDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>在bo里面代码:
package com.web.bo.Home;import java.util.ArrayList;
import java.util.List;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;import com.web.dao.Home.TTreeDao;
import com.web.po.TAuthority;
import com.web.po.TRole;
import com.web.po.TTree;public class TTreeBo { private TTreeDao tTreeDao;
private TAuthorityBo tAuthorityBo; public TTreeDao getTTreeDao() {
return tTreeDao;
}
public void setTTreeDao(TTreeDao treeDao) {
tTreeDao = treeDao;
}
public TAuthorityBo getTAuthorityBo() {
return tAuthorityBo;
}
public void setTAuthorityBo(TAuthorityBo authorityBo) {
tAuthorityBo = authorityBo;
}
/**
* 根据角色查找出对应的功能
* @param role
* @return
*/
public List<TTree> getTree(TRole tRole){
TAuthority ta=new TAuthority();
ta.setTRole(tRole);
List<TTree> list=new ArrayList<TTree>();
//tAuthorityBo.findByRole(ta)会返回一个List<TAuthority>
for(TAuthority t:tAuthorityBo.findByRole(ta)){
list.add(t.getTTree());
}
return list;
}
public static void main(String[] args) {
TRole tRole=new TRole();
tRole.setName("dd");
ApplicationContext context=new FileSystemXmlApplicationContext("src/applicationContext.xml");
TTreeBo bo=(TTreeBo)context.getBean("TTreeBo");
List<TTree> list=bo.getTree(tRole);
System.out.println(list.size());
}
}
求各位大侠帮忙解决,先谢谢了
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 创建sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>file:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 事务管理器 -->
<bean id="tm" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 2.0事务 -->
<tx:advice id="txadvice" transaction-manager="tm">
<tx:attributes>
<tx:method name="get*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice> <aop:config>
<aop:pointcut id="bizs"
expression="execution(* bo.*.*(..))" />
<aop:advisor advice-ref="txadvice" pointcut-ref="bizs" />
</aop:config>
<!-- bo配置 -->
<bean id="tTreeBo" class="com.web.bo.Home.TTreeBo">
<property name="tTreeDao"> <!--这里报错No setter found for property 'tTreeDao' in class 'com.web.bo.Home.TTreeBo'-->
<ref local="tTreeDao"/>
</property>
<property name="tAuthorityBo"><!--这里报错No setter found for property 'tAuthorityBo' in class 'com.web.bo.Home.TTreeBo'--> <ref local="tAuthorityBo"/>
</property>
</bean>
<bean id="tAuthorityBo" class="com.web.bo.Home.TAuthorityBo">
<property name="tAuthorityDao"> <!--这里报错No setter found for property 'tAuthorityDao' in class 'com.web.bo.Home.TAuthorityBo'--> <ref local="tAuthorityDao"/>
</property>
</bean>
<!-- dao配置 -->
<bean id="tTreeDao" class="com.web.dao.Home.TTreeDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="tAuthorityDao" class="com.web.dao.Home.TAuthorityDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>在bo里面代码:
package com.web.bo.Home;import java.util.ArrayList;
import java.util.List;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;import com.web.dao.Home.TTreeDao;
import com.web.po.TAuthority;
import com.web.po.TRole;
import com.web.po.TTree;public class TTreeBo { private TTreeDao tTreeDao;
private TAuthorityBo tAuthorityBo; public TTreeDao getTTreeDao() {
return tTreeDao;
}
public void setTTreeDao(TTreeDao treeDao) {
tTreeDao = treeDao;
}
public TAuthorityBo getTAuthorityBo() {
return tAuthorityBo;
}
public void setTAuthorityBo(TAuthorityBo authorityBo) {
tAuthorityBo = authorityBo;
}
/**
* 根据角色查找出对应的功能
* @param role
* @return
*/
public List<TTree> getTree(TRole tRole){
TAuthority ta=new TAuthority();
ta.setTRole(tRole);
List<TTree> list=new ArrayList<TTree>();
//tAuthorityBo.findByRole(ta)会返回一个List<TAuthority>
for(TAuthority t:tAuthorityBo.findByRole(ta)){
list.add(t.getTTree());
}
return list;
}
public static void main(String[] args) {
TRole tRole=new TRole();
tRole.setName("dd");
ApplicationContext context=new FileSystemXmlApplicationContext("src/applicationContext.xml");
TTreeBo bo=(TTreeBo)context.getBean("TTreeBo");
List<TTree> list=bo.getTree(tRole);
System.out.println(list.size());
}
}
求各位大侠帮忙解决,先谢谢了
<bean id="tAuthorityBo" class="com.web.bo.Home.TAuthorityBo">
这个类呢代码贴得乱糟糟 谁会看啊
没有找到 tTreeDao 的set方法。
你看你怎么配置的。
package com.web.bo.Home;import java.util.ArrayList;
import java.util.List;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;import com.web.dao.Home.TTreeDao;
import com.web.po.TAuthority;
import com.web.po.TRole;
import com.web.po.TTree;public class TTreeBo { private TTreeDao tTreeDao;
private TAuthorityBo tAuthorityBo;
public TTreeDao getTTreeDao() {
return tTreeDao;
}
public void setTTreeDao(TTreeDao treeDao) {
tTreeDao = treeDao;
}
public TAuthorityBo getTAuthorityBo() {
return tAuthorityBo;
}
public void setTAuthorityBo(TAuthorityBo authorityBo) {
tAuthorityBo = authorityBo;
}
/**
* 根据角色查找出对应的功能
* @param role
* @return
*/
public List<TTree> getTree(TRole tRole){
TAuthority ta=new TAuthority();
ta.setTRole(tRole);
List<TTree> list=new ArrayList<TTree>();
//tAuthorityBo.findByRole(ta)会返回一个List<TAuthority>
for(TAuthority t:tAuthorityBo.findByRole(ta)){
list.add(t.getTTree());
}
return list;
}
public static void main(String[] args) {
TRole tRole=new TRole();
tRole.setName("dd");
ApplicationContext context=new FileSystemXmlApplicationContext("src/applicationContext.xml");
TTreeBo bo=(TTreeBo)context.getBean("TTreeBo");
List<TTree> list=bo.getTree(tRole);
System.out.println(list.size());
}
}