SSH spring代理sessionFactory 配置泛型中丢失
 package ssh.action;

import java.text.DecimalFormat;
import java.util.List;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import ssh.dao.ModelDrivenBaseAction;
import ssh.entity.BookCard;
import ssh.service.IndexService;

//创建IndexAction(action类)继承ActionSupport接口
public class IndexAction extends  ModelDrivenBaseAction<BookCard> {

    private static final long serialVersionUID = 1L;

    //声明service,但不给它创建具体的实现类的实例,



    //编写execute()方法
    public String execute() {

        //获取IndexService实例,调用getAllBookCard()方法
        //将结果保存到List集合里
System.out.println("IndexAction1-------");
        List<BookCard> myBookCardList = is.getAll();
        System.out.println("IndexAction2-------");

        //将查询出来的结构集打印到控制台
        System.out.println("结果集:"+myBookCardList.size());

        //获取Context上下文对象
        ActionContext ac = ActionContext.getContext();
        //将myBookCardList集合添加到上下文对象里
        ac.put("myBookCardList", myBookCardList);

        //返回一个字符串
        return "success";
    }



}package ssh.action;

import java.text.DecimalFormat;
import java.util.List;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import ssh.dao.ModelDrivenBaseAction;
import ssh.entity.BookCard;
import ssh.service.IndexService;

//创建IndexAction(action类)继承ActionSupport接口
public class IndexAction extends  ModelDrivenBaseAction<BookCard> {

    private static final long serialVersionUID = 1L;

    //声明service,但不给它创建具体的实现类的实例,



    //编写execute()方法
    public String execute() {

        //获取IndexService实例,调用getAllBookCard()方法
        //将结果保存到List集合里
System.out.println("IndexAction1-------");
        List<BookCard> myBookCardList = is.getAll();
        System.out.println("IndexAction2-------");

        //将查询出来的结构集打印到控制台
        System.out.println("结果集:"+myBookCardList.size());

        //获取Context上下文对象
        ActionContext ac = ActionContext.getContext();
        //将myBookCardList集合添加到上下文对象里
        ac.put("myBookCardList", myBookCardList);

        //返回一个字符串
        return "success";
    }



}




2个回答

 package ssh.dao;

import javax.annotation.Resource;

import ssh.service.IndexService;

public class BaseAction {
    protected IndexService is;

    public IndexService getIs() {
        return is;
    }

    public void setIs(IndexService is) {
        this.is = is;
    }

}

 package ssh.dao;

import java.util.List;

import ssh.entity.BookCard;

//创建IndexDao(接口类)
public interface IndexDao<T> {

    public List<T> getAll();

}
 package ssh.dao;

import java.util.List;

import ssh.entity.BookCard;

//创建IndexDao(接口类)
public interface IndexDao<T> {

    public List<T> getAll();

}
 package ssh.dao;



import ssh.util.GenericsUtils;

import com.opensymphony.xwork2.ModelDriven;

public class ModelDrivenBaseAction<T> extends BaseAction implements ModelDriven<T> {

    // ===================== 对ModelDriven的支持 ====================
    // 收集页面数据,对象
    protected T model;

    public ModelDrivenBaseAction() {
        try {
            System.out.println("————————>ModelDrivenBaseAction");
            // 通过反射获取T的真是类型
            //ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
            //Class<T> clazz = (Class<T>) pt.getActualTypeArguments()[0];
            Class<T> clazz =GenericsUtils.getSuperClassGenricType(getClass(), 0);
            model = clazz.newInstance();
    } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public T getModel() {
        return model;
    }

}

 package ssh.service;

import java.util.List;

import ssh.dao.IndexDao;
import ssh.entity.BookCard;

//创建一个IndexService接口类
public interface IndexService extends IndexDao<BookCard>{



}
 package ssh.service;

import java.util.List;

import org.hibernate.SessionFactory;



import ssh.dao.IndexDao;
import ssh.dao.IndexDaoImpl;
import ssh.entity.BookCard;

//创建IndexServiceImpl(实现类)实现IndexService接口
public class IndexServiceImpl extends IndexDaoImpl<BookCard> implements IndexService {


    //dao实例使用注入方式
    private IndexDao<BookCard> id;
    //用于注入使用



    public void setId(IndexDao<BookCard> id) {
        System.out.println("IndexServiceImpl"+this.getClass());
        this.id = id;


    }



}
 package ssh.util;  
 import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

 public class GenericsUtils  {    
     /**    
      * 通过反射,获得定义Class时声明的父类的范型参数的类型.    
      * 如public BookManager extends GenricManager<Book>    
      *    
      * @param clazz The class to introspect    
      * @return the first generic declaration, or <code>Object.class</code> if cannot be determined    
      */    
     public static Class getSuperClassGenricType(Class clazz) {    
         return getSuperClassGenricType(clazz, 0);    
     }    

     /**    
      * 通过反射,获得定义Class时声明的父类的范型参数的类型.    
      * 如public BookManager extends GenricManager<Book>    
      *    
      * @param clazz clazz The class to introspect    
      * @param index the Index of the generic ddeclaration,start from 0.    
      */    
     public static Class getSuperClassGenricType(Class clazz, int index) throws IndexOutOfBoundsException {    

         Type genType = clazz.getGenericSuperclass();    

    if (!(genType instanceof ParameterizedType)) {    
        return Object.class;    
    }    

    Type[] params = ((ParameterizedType) genType).getActualTypeArguments();    

    if (index >= params.length || index < 0) {    
        return Object.class;    
    }    
    if (!(params[index] instanceof Class)) {    
        return Object.class;    
    }    
    return (Class) params[index];    
}    
 } 
 <?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:p="http://www.springframework.org/schema/p"  
        xmlns:aop="http://www.springframework.org/schema/aop"   
        xmlns:context="http://www.springframework.org/schema/context"  
        xmlns:jee="http://www.springframework.org/schema/jee"  
        xmlns:tx="http://www.springframework.org/schema/tx"  
        xsi:schemaLocation="    
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd  
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd  
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd  
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
    <!-- 类似于财务部门一样,类就是钱,所有需要类的实例都由srping去管理 -->
    <bean id="myIndexAction" class="ssh.action.IndexAction" scope="prototype">
        <!-- setIs(myIndexService) -->
        <property name="is" ref="myIndexService"/>
    </bean>

    <!-- myIndexService = new ssh.service.IndexServiceImpl() -->
    <bean id="myIndexService" class="ssh.service.IndexServiceImpl" scope="prototype">
        <property name="id" ref="myIndexDao"/>
    </bean>

    <bean id="myIndexDao" class="ssh.dao.IndexDaoImpl" scope="prototype">
        <!-- 把sessionFactory 注入给IndexDao -->
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

     <!-- 添加sessionFactory bane ,注意,该类是Spring提供的 -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" scope="prototype">
        <!-- 注入Hibernate 配置文件路径,前面要加上  classpath:-->
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
    </bean>

</beans>
 <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC 
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <!-- 数据库连接配置 -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://121.42.167.134:3306/test?useUnicode=true</property>
        <property name="connection.username">root</property>
        <property name="connection.password">tianqi110</property>
        <!-- 每个数据库都有1个,针对特定的关系型数据库生成优化的SQL -->
        <property name="dialect">org.hibernate.dialect.SQLServer2008Dialect</property>

        <!-- 设置默认的数据库连接池 -->
        <property name="connection.pool_size">5</property>

        <!-- 显示SQL -->
        <property name="show_sql">true</property>

        <!-- 格式化SQL -->
        <property name="format_sql">true</property>

        <!-- 根据schema更新数据表的工具 -->
        <property name="hbm2ddl.auto">update</property>        

        <!-- 数据表映射配置文件 -->
        <mapping resource="ssh/entity/BookCard.hbm.xml"/>

    </session-factory>
</hibernate-configuration>
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<!-- 上面的头,注意版本,从样例里复制过来 showcase.war\WEB-INF\src\java\struts.xml -->

<struts>
    <!-- 告知Struts2运行时使用Spring来创建对象 -->
    <constant name="struts.objectFactory" value="spring" />

    <!-- 第1步:先定义一个包 -->
    <package name="mypck001" extends="struts-default">
        <!-- 第2步:定义一个action,配置跳转信息 name 类似于Servlet @WebServlet("/IndexServlet") 
            http://xxxx/xxx/Index.action http://xxxx/xxx/Index class 对应于自己写的Action类 当不写method属性时,默认调用的是execute
            class="ssh.action.IndexAction" ** new ssh.action.IndexAction()
            设计思想:关心了具体的实现类必须改为不要关注那个实现类 加入spring后,struts的action节点的class属性意义发生变化,直接引用spring帮忙创建的实例 
        -->
        <action name="Index" class="myIndexAction">
            <!-- 跳转是forward/WEB-INF/是防止jsp不经过action就可以访问-->
            <!-- result接收返回的字符串,然后做对应的事情 -->
            <result name="success">/WEB-INF/jsp/index.jsp</result>
        </action>
    </package>
</struts>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
ssh集成中spring配置问题(sessionFactory)
xmlns="http://www.springframework.org/schema/beans"rn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"rn xmlns:p="http://www.springframework.org/schema/p"rn xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.SQLServerDialectrn rn rn rn rnrnrn就是我注释的这些映射,注释了发布就没有错,不注释就说我rnrnError creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]rn错误创建名为'的SessionFactory在类路径资源定义[applicationContext.xml中]豆
SSH中sessionFactory==null
我系统启动时,启动了一个Servlet,在里面调用了HibenateProductDaoImpl的findAllProducts()方法,返回一个产品信息的集合.rn但是该方法在执行HibernateTemplate的find(hql)方法时出错;rn查询操作不能完成;以下是错误提示。rnrn信息: SessionListener: contextInitialized()rnsessionFactory==>nullrnlog4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).rnlog4j:WARN Please initialize the log4j system properly.rnsessionFactory==>org.hibernate.impl.SessionFactoryImpl@1ae90crn2008-8-30 23:58:27 org.apache.catalina.core.ApplicationContext logrn严重: StandardWrapper.Throwablernjava.lang.NullPointerExceptionrn at com.gjun.dao.HibenateProductDaoImpl.findAllProduct(HibenateProductDaoImpl.java:28)rn at com.gjun.servlet.InitServlet.init(InitServlet.java:65)rn at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)rn at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)rn at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rn2008-8-30 23:58:27 org.apache.catalina.core.StandardContext loadOnStartuprnrnrn
Spring Mybatis配置动态SqlSessionFactory
SqlMap-Config.xmlrn rn rn rn rn rnrnUser.xmlrnrnrn rn rnrn rn select rn User_ID as "User_ID", rn User_Name as "User_Name" rn from UserMaster_Table U where U.User_ID = #User_ID rn rnrnrnUserrnpublic class User // 用户rn private String User_ID; // 员工ID rn private String User_Name; // 员工名称 rnrn public String getUser_ID() rn return User_ID;rn rn public void setUser_ID(String user_ID) rn User_ID = user_ID;rn rn public String getUser_Name() rn return User_Name;rn rn public void setUser_Name(String user_Name) rn User_Name = user_Name;rn rnrnrnjava:rnrnBasicDataSource dataSource=new BasicDataSource();rndataSource.setDriverClassName("..");rndataSource.setUrl("..");rndataSource.setUsername("..");rndataSource.setPassword(".."); rnTransactionFactory transactionFactory = new JdbcTransactionFactory();rnEnvironment environment = new Environment("development", transactionFactory, dataSource);rnConfiguration configuration = new Configuration(environment);rnconfiguration.addMapper(User.class);rnSqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);rnSqlSession sqlSession=sqlSessionFactory.openSession(); rnsqlSession.selectOne("cn.com.sjb.pss.business.entity.User.findUserID", User_ID);rnrn报错rnjava.lang.IllegalArgumentException: Mapped Statements collection does not contain value for cn.com.sjb.pss.business.entity.User.findUserIDrnrn
在Spring中配置SessionFactory的二种方式
在Spring中配置SessionFactory的二种方式 第一种方式: 把Hibernate的配置文件hibernate.cfg.xml配置到applicationContext.xml中 &amp;lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;&amp;g...
spring中对sessionFactory配置的疑问
spring中配置sessionFactory是 [code=&quot;xml&quot;][/code] 配置中没有指明factory-method,但返回的实例是SessionFactory的实例,而不是LocalSessionFactoryBean类的实例,是因为LocalSessionFactoryBean类是FactoryBean接口的实现类。 context.getBean(&quot;sessionF...
急!!!spring 中配置的sessionFactory能否一劳永逸
rn rn rn rnrn然后由子类继承BaseDAO如rnrn这样就可以避免每次都在DAO中注入sessionFactory了rn rn这样做是否可行?请各位大虾指点一下
spring 泛型配置
我在项目中用到了泛型,也主要是为了学习这方面知识,但是在配置SPRING的时候总是有错,请各位指点一下rn下面是applicationContext-service.xml的配置rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIRED,readOnlyrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn下面是错误提示rnorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountInfoImpl' defined in file [D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes\com\dscver\xml\spring\applicationContext-service.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.Class]: Could not convert constructor argument value of type [com.abc.AccountInfo] to required type [java.lang.Class]: Failed to convert value of type [com.abc.AccountInfo] to required type [java.lang.Class]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.abc.AccountInfo] to required type [java.lang.Class]: no matching editors or conversion strategy found
spring 泛型DAO配置
我写了个BaseDAO有泛型的:rnpublic abstract class BaseDAO implements IBaseDAOrn请问我在applicationContext.xml里要怎么配置BaseDAO这个类啊。rn我原来是这样配置的,但有错啊:rn rn rn rn rn rnrnrn代码如下:rn[code=HTML]rnrnrnrnrn rn rn rn rn classpath:hibernate.cfg.xmlrn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn[/code]
SSH笔记-Spring的泛型依赖注入
1、作用:为子类注入子类对应的泛型类型的成员变量的引用 2、文件 ①TestMain.java:测试类 ②Info.java:数据模型 ③InfoService.java:测试继承BaseService ④InfoRepository.java:测试继承BaseRepository ⑤BaseService.java:被继承的类 ⑥BaseRepository.java:被继承的类 ...
ssh配置 sessionFactory依赖的jar包找不到
所有都是myeclipse自动生成的代码。nspring配置文件:n![图片说明](https://img-ask.csdn.net/upload/201806/02/1527938194_887948.png)n如果改成org.springframework.orm.hibernate4.LocalSessionFactoryBeann配置文件不报错了,但是通过sessionFactory获取的session为null。nn是myeclipse的错误还是我操作的错误(少导或导错了jar包)?n怎么解决
Spring 事务代理配置
Spring 事务代理配置 Spring 事务代理配置
spring 事务代理配置
spring 事务代理配置
struts1代理spring的配置
rn rn rn rn rnrn rn rn rn //name的作用?rn //ref cocal的意思。rn rn rn rn rnrnrn上面的配置什么意思?求详解。spring配置中那么属性需要在对应的类中做什么样的操作?
ssh框架配置-在spring中配置数据源
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;gb2312&quot;?&amp;gt; &amp;lt;!-- Spring配置文件的文件头,包含DTD等信息--&amp;gt; &amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&amp
SSH运行时sessionFactory报错
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sessionFactory' is requiredn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)n at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)n at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)n at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)n at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)n at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)n at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)n at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)n at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)n at com.ffour.yixing.action.YixingUserInfoLogin.(YixingUserInfoLogin.java:22)n at com.ffour.yixing.action.YixingUserInfoLogin.main(YixingUserInfoLogin.java:49)nCaused by: java.lang.IllegalArgumentException: Property 'sessionFactory' is requiredn at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:330)n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)n ... 13 moren
ssh sessionFactory 问题
最近想做一个ssh整合,但遇到了一个麻烦,总是报错,如果不把映射文件加上去就没事,一加就报错rnrn错误提示如下:rn严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/E:/Program%20Files/Tomcat%206.0/webapps/ssh2/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Vrnrn请各位大侠帮帮小弟,小弟先谢谢啦!!!
ssh('sessionFactory' or 'hibernateTemplate' is required)
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416)rn at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:554)rn at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:164)rn at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)rn at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)rn ... 41 morernCaused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is requiredrn at org.springframework.orm.hibernate3.support.HibernateDaoSupport.checkDaoConfig(HibernateDaoSupport.java:118)rn at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)rn ... 53 morern2013-3-13 22:19:14 org.apache.catalina.core.StandardContext startrn严重: Error listenerStartrn2013-3-13 22:19:14 org.apache.catalina.core.StandardContext startrn严重: Context [/test_ano] startup failed due to previous errorsrn2013-3-13 22:19:14 org.apache.catalina.core.ApplicationContext logrn信息: Closing Spring root WebApplicationContextrn2013-3-13 22:19:14 org.apache.coyote.http11.Http11Protocol startrn信息: Starting Coyote HTTP/1.1 on http-8080rn2013-3-13 22:19:14 org.apache.jk.common.ChannelSocket initrn信息: JK: ajp13 listening on /0.0.0.0:8009rn2013-3-13 22:19:14 org.apache.jk.server.JkMain startrn信息: Jk running ID=0 time=0/20 config=nullrn2013-3-13 22:19:14 org.apache.catalina.startup.Catalina startrn信息: Server startup in 1888 msrnrnspring.xmlrnrnrnrn rn rn classpath:jdbc.propertiesrn rn rn rn rn rnrn rn rn rn rn rn rnrn rn rn rn rn org.ssh.anotation.modelrn rn rn rn rn rn org.hibernate.dialect.MySQL5Dialectrn truern creatern truern rn rn rn rn rn rn rnrn rn rn rnrnrn rn rn rn rnrnrn rn rn rn rn rn rn
SSH框架整合sessionFactory不可用
最近在做SSH三层架构的结合时总是遇到这个问题严重:Exception sending contextinitialized event to listener instance of classorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationExc
ssh 整合 得不到sessionFactory
applicationContext.xmlrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rn rn com/ly/entity/Student.hbm.xmlrn rn rn rn rn rn rn rnrnrnStudentDAOrnrnpublic class StudentDAO extends HibernateDaoSupport rn private static final Log log = LogFactory.getLog(StudentDAO.class);rnrn // property constantsrn public static final String PASSWORD = "password";rnrn protected void initDao() rn // do nothingrn rnrn public void save(Student transientInstance) rn// log.debug("saving Student instance");rn// try rn// getHibernateTemplate().save(transientInstance);rn// log.debug("save successful");rn// catch (RuntimeException re) rn// log.error("save failed", re);rn// throw re;rn// rn [color=#FF0000]SessionFactory sf =this.getSessionFactory();rn System.out.println(sf.getClass());[/color] rnrn运行到这里 空异常了
内网配置git ssh代理
SB公司不开放公网,内网使用代理上网,带来了无数麻烦,此其一,记录,以备不时之需。一 、设置git的user name和email:git config --global user.name "wandererparsifal"git config --global user.email "wandererparsifal@gmail.com"二、生成SSH密钥:ssh-keygen -t rsa
SSH之配置spring
一、导入约束    1.src下创建application.xml文件,并在该文件中写入约束信息&amp;lt;beans xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:context=&quot;http://www.sprin...
GIT配置SSH-KEY 配置SSH代理
https://help.github.com/categories/authenticating-to-github/ 还是官方文档好用~ git的代理分2种,当你从http网址复制过来 git clone 走的是http /https 的协议 当你用 ******.git 来git clone的时候 走的是SSH的协议,所以只需要为ssh设置代理就可以了 为ssh设置代理有很多工...
Spring中配置自动的事务代理
公司项目中配置了Spring 的事务代理, 不用在数据库操作的时候麻烦写很多的事务开始和回滚的代码了。   &amp;lt;!--事务管理器--&amp;gt; &amp;lt;bean id=&quot;txManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&amp;gt; &amp;lt;pro...
Spring的sessionFactory的初级问题。
本人新手,现在总算是能配出简单的Bo dao po action 的appliactionContext.xml文件了。rnrequest也能进action了,但是进了dao层后发觉从Spring注入的sessionFactory一直为null。rn不晓得这sessionFactory倒是是干什么用的。Hibernate的数据库链接对象吗?但是为什么为空??rn 还有就是,大家写的项目的时候是不是都用rn[code=Java]rn lstResult = this.getHibernateTemplate().find(strHql);rn[/code]rn这来得到po。感觉这样好像扩展性能不强。rn应该怎么做才是比较好的方法呢?rn谢谢,请知道的朋友教我下。。。rn
spring hibernate sessionfactory
在applicationcontext.xmlrn rn rn rn rn rn在StudentDao里面应该有个set方法,但是怎么老是说SessionFactory 找不到呢
SSH整合中出现sessionFactory无法创建
前提条件:SSH项目整合中配置流程完全没问题    在进行JUnit测试时报错, 原因有两种情况:              1、项目所导jar包有问题——认真检查jar包               2、开发工具(eclipse、myeclipse)与jar版本的不兼容性      这次整合中出现的情况:        Caused by: org.springframework
SSH整合中sessionFactory创建失败问题
Error creating beanwith name 'sessionFactory' defined in class path resource [bean.xml] must specify an identifier type  Invocation of init method failed; nestedexception is org.hibernate.
Spring中泛型依赖注入
Spring中泛型依赖注入
spring boot 项目代理配置
最近公司需要做一个项目,项目是前后端分离的,前端技术用的vue+element,后端用的是spring boot+shiro,为了开发的方便,项目分为了多个,后端主要提供接口,前段只放页面,在发布的过程中,由于需要跨域访问数据、获取数据,所以会出现跨域的问题。 在开发的时候,我们前端开发的时候是有设置vue 代理的(vue代理设置请看我另外的一篇博客),为了后期的方便,我们考虑到前端项目也设置代
SSH整合的常见异常SessionFactory问题
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).rnlog4j:WARN Please initialize the log4j system properly.rnException in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExceptionrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)rn at java.security.AccessController.doPrivileged(Native Method)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)rn at test.Test.main(Test.java:15)rnCaused by: java.lang.reflect.MalformedParameterizedTypeExceptionrn at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42)rn at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(ParameterizedTypeImpl.java:35)rn at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77)rn at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86)rn at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122)rn at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)rn at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:82)rn at java.lang.Class.getGenericInterfaces(Class.java:794)rn at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:161)rn at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:99)rn at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:88)rn at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)rn at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)rn ... 14 morern我在网上找了些文章,说是要找spring AOP下的删除asm2.2.3jar的包,但是我找不到这个包.....rn求大神[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]
ssh中struts2,spring,各配置说明
ssh中struts2.xml,spring.xml和web.xml,各配置说明
关于整合SSH的sessionFactory问题
哪位高手可以告诉我下 ,怎么用注解的方式向dao层注入sessionFactory,dao层的实现类是继承HibernateDaoSupport类的
注解方式配置SessionFactory的注入
之前程序中的SessionFactory都是通过hibernate的方式获取的: Configuration().configure("hibernate.cfg.xml").buildSessionFactory(); 因为一些问题想要改成Spring注入的方式,但是我的程序都是使用的注解的方式注入bean,为了保持一致性还是用@Bean来配置SessionFactory 首先
ssh 代理
1. 通过103.243.24.100的端口777代理 sudo ssh -fND 127.0.0.1:777 root@103.243.24.100 2. 通过ec2-52-25-165-207.us-west-2.compute.amazonaws.com的端口777代理 sudo ssh -fND 127.0.0.1:777 ubuntu@ec2-52-25-165-2
ssh代理
linux下一条简单指令就能实现代理: ssh -qTfnNg -D 7070 user@remote_ip windows代理软件Bitvise SSH Client
SessionFactory:使用与配置
&amp;lt;bean id=&quot;dataSource&quot; class=&quot;com.mchange.v2.c3p0. ComboPooledDataSource&quot; destroy-method=&quot;close&quot;&amp;gt; &amp;lt;!-- 指定连接数据库的驱动 --&amp;gt; &amp;lt;property name=&quot;driverClass&quot; value=&quot;
Spring中代理问题
我的MyEclipse环境下,在Spring框架下怎么无法实现MethodInterceptor接口(即,建类时加入此接口时选择框里没有)?rn
Spring 中的代理
Spring中有两种方式进行Bean的代理: 1。JDK 动态代理 JDK主要通过Proxy.newProxyInstance(Classloader, Interface[], InvocationHandler)方法,生成一个与目标类实现相同[b]接口[/b]的代理类,这也是为什么Spring中经常出现ClassCastException: $Proxy can not be cas...
SSH 拆分 Spring 配置和自动装配
er&amp;lt;/listener-class&amp;gt; &amp;lt;/listener&amp;gt; &amp;lt;context-param&amp;gt; &amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt; &amp;lt;param-value&amp;gt;classpath:spring-*.xml&amp;lt;/param-value&amp;gt; &amp;l
关于ssh Spring Bean的配置
情况如下:rn 项目中有一个Action,Action中有一个属性为项目中的一个实体类的集合(items),在配置完成后访问Action时抛出Invalid action class configuration that references an unknown class named异常,经过多次检查没有问题,于是我就把Action中的属性(实体类集合items)给注视了,当然相关的封装方法也注视了,再次访问Action就访问成功了,初步估计是在配置Bean节点的时候要设置items的property节点,但是我的items的值是从页面中过来的,通过Struts 2来初始化的,求大神指教该如何配置才能通过,我也设置了 dependency-check="none",但是不管用
相关热词 c# 线程结束时执行 c# kb mb 图片 c# 替换第几位字符 c#项目决定成败 c# 与matlab c# xml缩进 c#传感器基础 c#操作wps c# md5使用方法 c# 引用父窗口的组件