测试Spring整合hibernate、Struts2框架时,配置文件报错,看不懂

图片说明

报错:



Caused by: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 44; cvc-complex-type.2.4.a: 发现了以元素 'property' 开头的无效内容。

应以 '{"http://www.springframework.org/schema/beans":import,

"http://www.springframework.org/schema/beans":alias,

"http://www.springframework.org/schema/beans":bean,

WC[##other:"http://www.springframework.org/schema/beans"]}' 之一开头。

0

4个回答

不应该包含在bean里边么,你那上边的bean是个单标签啊

0

配置的位置不对,property是bean的子属性,需要包含在bean标签内

1

bean标签错了,property 包含在bean标签内,这代码写的真是奇葩,要么不要property,用还用一半,URL,name,password 不写property里面

1

下面的property应该是包含在datasource bean里面的,是该bean的属性。并且在前面配置datasource时不是用了p标签么,可以接着用这个的,不用写property。

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Spring整合Hibernate测试时报错
大家好,Spring 整合Hibernate时报错,用的是SQLServer2008数据库,大虾们帮看看这个异常是什么导致的,谢谢!。 数据库的jar包是sqljdbc4.jar. spring的关键配置如下:rndataSource的配置如下:rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnsessionFactory的bean配置:rn rn rn rn rn com/asm/bean/employee.hibernate.cfg.xmlrn rn rn rn rn hibernate.dialect=org.hibernate.dialect.SQLServerDialectrn rn hibernate.hbm2ddl.auto=updatern hibernate.show_sql=falsern hibernate.format_sql=falsern rn rn rnrnrnrn然后写了个Junit测试:rnpackage juint.test;rnrnrnimport org.junit.After;rnimport org.junit.Before;rnimport org.junit.Test;rnimport org.springframework.context.support.ClassPathXmlApplicationContext;rnrnpublic class EmployeeTest rnrn @Beforern public void setUp() throws Exception rn rnrn @Afterrn public void tearDown() throws Exception rn rn rn @Testrn public void save()rn new ClassPathXmlApplicationContext("beans.xml");rn rnrnrnrn
spring整合hibernate时配置文件
<?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:mvc="http://www.springframewo
spring整合struts2与hibernate核心配置文件
spring整合struts2与hibernate核心配置文件
Spring整合Hibernate和Struts2注解配置文件
<?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.sprin
spring整合hibernate时报错
rnrnrn rn rn rn classpath:conf/jdbc.propertiesrn rn rn rn rn rn rn rn rn rnrn rn rn rn rn com.BeNnovo.EmployeesManagement.coreCode.entityrn rn rn rn rn rn org.hibernate.dialect.SQLServerDialectrn rn truern rn rn rn rn rn rn rn rn rnrn rn rn rn rnrn rn rn rn rn rn rnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnrnrnrnrnpublic class TestEmployeesServicernrn ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");rn private EmployeesService employeesService = (EmployeesService) context.getBean("employeesService");rn rn private int page = 1;rn private int rows = 10;rn private long total;rn private long records;rnrn rn @Testrn public void createEmployees()rn rn EmployeesDTO employeesDTO = new EmployeesDTO();rn employeesDTO.setEmployeesName("admin");rn employeesDTO.setEmployeesPassword("admin");rn employeesDTO.setEmployeesIdentityCard("123434");rn employeesDTO.setEmpoyeesMaritalStatus(EmployeesMaritalStatus.MARRIED);rn employeesDTO.setEmployeesSex(EmployeesSex.MAN);rn for (int i = 0; i < 50; i++)rn rn employeesDTO.setEmployeesCode("B"+i);rn employeesService.createEmployees(employeesDTO);rn rn rn rn rn public EmployeesService getEmployeesService()rn rn return employeesService;rn rn @Resourcern public void setEmployeesService(EmployeesService employeesService)rn rn this.employeesService = employeesService;rn rnrnrnrnrnrnrnrnpublic class TemplateDAOImpl implements TemplateDAOrnrn private HibernateTemplate hibernateTemplate;rnrn public void save(T entity) throws DataAccessException rn hibernateTemplate.save(entity);rn rn rn rn public HibernateTemplate getHibernateTemplate()rn rn return hibernateTemplate;rn rn @Resourcern public void setHibernateTemplate(HibernateTemplate hibernateTemplate)rn rn this.hibernateTemplate = hibernateTemplate;rn rnrnrnrnrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeesDAO' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerErrorrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)rn at java.security.AccessController.doPrivileged(Native Method)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)rnCaused by: java.lang.ExceptionInInitializerErrorrn at com.BeNnovo.EmployeesManagement.coreCode.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:21)rn at com.BeNnovo.EmployeesManagement.coreCode.util.HibernateUtil.(HibernateUtil.java:11)rn at com.BeNnovo.EmployeesManagement.coreCode.dao.employeesManagerment.impl.EmployeesDAO.(EmployeesDAO.java:21)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:525)rn at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)rn at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)rn ... 39 morernCaused by: org.hibernate.HibernateException: /hibernate.cfg.xml not foundrn at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)rn at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453)rn at org.hibernate.cfg.Configuration.configure(Configuration.java:1475)rn at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)rn at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)rn at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)rn at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011)rn at com.BeNnovo.EmployeesManagement.coreCode.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)rn ... 48 morernrn整合后为什么还要去找那个/hibernate.cfg.xmlrn我使用的是xml方式,原来用的是annotation方式
struts2,hibernate,spring整合源码,配置文件,jar包
struts2,hibernate,spring整合过程的项目源码,以及配置文件,jar包
测试Spring整合hibernate/Struts2框架时,配置文件报奇怪的错误,求解
![图片说明](https://img-ask.csdn.net/upload/201604/13/1460561858_846413.png)nn![图片说明](https://img-ask.csdn.net/upload/201604/13/1460561870_21079.png)nn## 为什么会报无法识别property?
struts2与spring整合的配置文件
struts2与spring整合的配置:         org.springframework.web.context.ContextLoaderListener              contextConfigLocation   classpath:spring-*.xml              mvc     org.apac
Hibernate Struts2 Spring整合实例
自己写的一个SSH整合开发的实例,入门级的,思路清晰非常适合新手。
struts2 hibernate spring整合实例
struts2 hibernate spring 三大框架进行整合
struts2、Hibernate、Spring整合小问题
从struts.xml文件通过代理要跳到spring配置文件applicationContext.xml里面,但是在发布启动Tomcat时报错,代码好像没的什么错,不知道是不是哪没配置或是jar包问题。帮忙解决一下,在线等rnstruts.xml文件rnrnrn rn rn rn rn rn /success.jsprn /error.jsprn rn rn rnweb.xml文件rnrnrn rnrn rn contextConfigLocationrn /WEB-INF/applicationContext.xmlrn rn rn rn struts2rn rn org.apache.struts2.dispatcher.FilterDispatcherrn rn rn rn struts2rn /*rn rn rn rn index.jsprn rnrn
Struts2、Hibernate和Spring整合应用
Struts2、Hibernate和Spring整合应用
struts2 hibernate spring整合包
struts2 hibernate spring整合后的jar包,以及一个oracle驱动包,可以直接使用。
struts2、hibernate、spring整合
hibernate 把数据库中的数据与javabean中数据时刻保持一致Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架,用来整合struts是表现层框架,差不多就是界面设计
struts2,hibernate,spring整合的jar包
这是Struts2,Hibernate,Spring整合所需要的jar包
struts2 hibernate spring整合
struts2 hibernate spring整合开发
struts2 hibernate spring整合(出错的)
struts2 hibernate spring整合开发
struts2,hibernate,spring整合教程
在S2SH整合方面有问题的朋友们可以看一下,讲解简单明了,一看就懂,轻松搞定S2SH三个框架的整合。
struts2和spring整合时配置文件中的一点疑惑
我在网上看的rnrn[b]在Spring配置文件\WebContent\WEB-INF\applicationContext-action.xml中的相应配置为:[/b]rnrnrn        rn            rn        rnrnrn在Struts2配置文件WebContent\WEB-INF\struts-cfg\contract\struts.xml中的相应设置为:rnrnrn[color=#FF0000]由上面的XML知道,如果我们取得名为checkSoleContractNameAction的bean,Spring将通过反射调用一个com.heyang.module.contract.action.CheckSoleContractNameAction类的实例[/color]rnrnrn[b]但是我现在的项目中的spring和Struts2配置有点不一样,我的配置是这样的[/b]rnrn在Spring配置文件\WebContent\WEB-INF\applicationContext-action.xml中的相应配置为:rnrnrn        rn            rn        rnrnrn在Struts2配置文件WebContent\WEB-INF\struts-cfg\contract\struts.xml中的相应设置为:rnrnrn我的问题是 rn1.我要取得我在struts配置文件中配置的checkSoleContractName Action实例,是怎么得到的,是通过spring注入的还是由struts objectFactory生成的,还是由其他方法生成的。rnrn2.在实际项目中应该那种方法是推荐使用的。
spring整合hibernate时候报错
报错提示如下![图片说明](https://img-ask.csdn.net/upload/201612/07/1481046913_593729.png)nn我引入的夹包如下![图片说明](https://img-ask.csdn.net/upload/201612/07/1481046933_177379.png)nn我百度了好多,百度上都说是struts2夹包出了问题,但是现在我做的就是spring和hibernate的整合,还没涉及到struts呀~现在搞到了晚上快两点了,愁死我了,希望大神不啬吝教。谢谢谢谢~如果可以的话请加我QQ:243581579
spring整合hibernate报错
![图片说明](https://img-ask.csdn.net/upload/201612/07/1481112117_857176.jpg)n不加这一行好好的,加上这一行之后就报错了,报错如下![图片说明](https://img-ask.csdn.net/upload/201612/07/1481112157_324639.png)n百度一下有的说是少引用了aspectjweaver jar包 但是我引用之后还是这样报错,没有变化,引入夹包如下![图片说明](https://img-ask.csdn.net/upload/201612/07/1481112424_158810.png)n搞了好长时间了,求各位大神指教~n
hibernate和spring整合报错
整合SSH框架报错,新手,无解,求救:::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 ServletContext resource [/WEB-INF/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;)Vrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)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:220)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:729)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)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:117)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:566)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Vrn at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)rn at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)rn at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)rn at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)rn at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)rn at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)rn at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)rn at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)rn at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)rn at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)rn at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)rn at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)rn at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135)rn at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)rn at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56)rn at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:295)rn at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434)rn at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)rn at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)rn at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)rn at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)rn ... 39 morern2009-3-9 16:05:52 org.apache.catalina.core.StandardContext startrn严重: Error listenerStart
框架学习之spring整合hibernate、struts2框架-01基础配置
spring概述 spring是一个容器框架,创建bean,维护bean之间的关系 spring可以管理web层,持久层,业务层,dao层,spring可以配置各个层的组件,并且维护各个层的关系 spring整合struts2之配置web.xml配置 1. 除了在文件中配置使用struts2的过滤器外,还需要配置一个spring框架提供的一个监听器 2. 同时配置一个applicationCon
struts2和spring整合时注意
在把struts2和spring的依赖包放到lib下面之后,另外加一个struts2-spring-plugin-2.3.14.3.jar 加入这个包必须要在web.xml中配置(哪怕你只是使用struts2): org.springframework.web.context.ContextLoaderListener ...
struts2 Hibernate spring整合在线考试系统
http://blog.csdn.net/zhiweiv/archive/2008/09/22/2963504.aspx 项目系列说明~~~~~~~~~~~~~~`
关于struts2和hibernate和spring整合的书籍
大家好呀 我最近想买本关于struts2和sprign和hibernate整合的书籍 谁能推荐下有什么好书吗 谢谢呀
Struts2、Hibernate、spring整合过程总结
Struts2、Hibernate、spring整合过程总结 相关配置版本:jdk1.5,Tomcat 6.0 , Myeclipse7.0 [color=red]1[/color].打开MyEclipse,创建一个web project项目,输入项目名,如mytest,下面的J2EE Specification Level选择“Java EE 5.0”,然后finish. ...
struts2,hibernate,spring整合开发用户注册
struts2,hibernate,spring整合开发用户注册,用了MyEclipse和mysql
spring整合hibernate与struts2所需jar包
spring整合hibernate与struts2所需jar包
struts2 hibernate spring整合小项目
struts2 hibernate spring整合小项目
Struts2、Hibernate、spring整合过程总结
1、Struts2、Hibernate、spring整合过程总结           http://www.cnblogs.com/flyoung2008/archive/2011/09/03/2165833.html(很好)     http://hi.baidu.com/gujianting2010/blog/item/1ae1f9f0ca3be261dcc4...
Spring整合Hibernate时的问题
在Spring整合Hibernate时,我用DAO的方式写了一个静态代理类IUserDAOProxy,并在其上使用了Annotation 使Spring容器将其初始化为一个名为proxy的Bean,并在其方法addUser加上了事务的Annotation,之后再Junit单元测试时从ApplicationContext中getBean("proxy")时得到的并不是IUserDAOProxy类型的对象,而是一个动态代理类的对象,若没有在其上加事务的话,得到的就是IUserDAOProxy类的对象,这是为什么呢?rnrn1.有一个静态代理类:rn @Component("proxy")rnpublic class IUserDAOProxy implements IUserDao rn rn private IUserDao uDao;rn private MyLogService myLogService;rn rn rn public MyLogService getMyLogService() rn return myLogService;rn rn @Resourcern public void setMyLogService(MyLogService myLogService) rn this.myLogService = myLogService;rn rn public IUserDAOProxy() rn rn public IUserDAOProxy( IUserDao uDao)rn this.uDao=uDao;rn rn @Resourcern public void setuDao( IUserDao udao) rn rn this.uDao = udao;rn rn @Overridern @Transactionalrn public void addUser(User user) rn uDao.addUser(user);rn System.out.println("************"+this.getClass().getName()+"****************");rn Log mylog=new Log();rn mylog.setMessage("addUser增加用户了");rn myLogService.addLogBefore(mylog);rn rnrn2.如上可见在此类上加上了事务。rn3.在JUnit用到了下面代码rn ApplicationContext beanfactory=new ClassPathXmlApplicationContext("beans.xml");rn // IUserDAOProxy userproxy=(IUserDAOProxy)beanfactory.getBean("proxy"); rn IUserDao userproxy=(IUserDao)beanfactory.getBean("proxy");rn 从beanFactory中得到的类名是$Proxy11,而不是IUserDAOProxy.rn4.这个代理类实现的接口有:rn***************实现的接口*****************rninterface cn.yang.dao.IUserDaorninterface org.springframework.aop.SpringProxyrninterface org.springframework.aop.framework.Advisedrn5.其父类是:java.lang.reflect.Proxyrn 构造方法只有一个rn $Proxy11(java.lang.reflect.InvocationHandler)rn
struts2与spring整合报错,求救啊!
部署好启动tomcat时一直出这个错:rn严重: Dispatcher initialization failedrnUnable to load configuration. - bean - jar:file:/D:/tomcat-6.0.20/webapps/OA/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178rnrn一堆错误都由上面那个引起。。。。rnrn严重: Error filterStartrn2010-6-28 16:14:39 org.apache.catalina.core.StandardContext startrn严重: Context [/OA] startup failed due to previous errorsrnrn配置文件没问题啊,包引入也没问题,都在lib下。rn弄一下午崩溃了……rn--------------------------------------------------------------------------------------------------------rnweb.xml----------rnrnrnrnrnrn org.springframework.web.context.ContextLoaderListenerrnrnrnrn struts2rn org.apache.struts2.dispatcher.FilterDispatcherrnrnrnrn struts2rn /*rnrnrnrn---------------------------------------------------------------------------------------rnrnstruts.xml----rn rnrnrn rn rn /result.jsprn /login.jsprn rn rn rnrn--------------------------------------------------------------------------------rnapplicationContext.xml----rnrnrnrn rn rn rn rn rn rnrn
hibernate和struts2所需的配置文件
hibernate和struts2所需的配置文件
Spring整合Hibernate Annotation配置报错~~~~~~~
严重: 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 ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super classrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)rn at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)rn at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)rn at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)rn at java.util.concurrent.FutureTask.run(FutureTask.java:138)rn at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)rn at java.lang.Thread.run(Thread.java:662)rnCaused by: java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super classrn at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)rn at java.lang.ClassLoader.defineClass(ClassLoader.java:616)rn at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)rn at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)rn at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)rn at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:187)rn at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)rn at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)rn at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)rn ... 20 morern---------------------------------------------------------------------------------------------------------rnsessionFactory配置rn rn rn rn rn rn rn rn com.wyf.modelrn rn rn rn rn rn truern truern org.hibernate.dialect.Oracle10gDialectrn truern rn rn rn-----------------------------------------------------------------------------------------------------------rn用*.hbm.xml整合好后我想改成用Annotation的,然后就改了下sessionFactory就出错了,rn谁能帮忙解决下非常感激rn[img=http://pic.wenwen.soso.com/p/20110402/20110402221516-558973392.jpg][/img]
Struts2框架的配置文件分析
配置文件信息: 名称 位置 内容 能否能直接修改 default.properties struts2-core-2.3.jar/org/apache/struts2/default.properties 通过属性的形式配置struts2的参数 不能 struts-default.xml struts2-core-2.3.jar/struts-d...
Hibernate的配置文件与测试
首先新建java project项目,,笔者使用hibernate的版本是4.2.21 搭建hibernate环境: src新建文件夹,导入以下jar包: required目录下的所有jar包 optional/c3p0目录下的所有jar包 optionnal/ehcache/slf4j-api-1.6.1.jar jpa-metamodel-generator目录下所有jar包
hibernate 配置文件报错
![图片说明](https://img-ask.csdn.net/upload/201701/03/1483440537_361655.png)n之前是create没问题,换成update就报错,但还是能执行。不过第二天数据库就报10061错误,不清楚问题到底出在哪里。下面是我的全部代码。nn配置文件:nnnnnnnn n rootn jdbc:mysql://localhost:5656/mysqln org.hibernate.dialect.MySQLDialectn 123456n com.mysql.jdbc.Drivernn truen truen updaten n nnnn测试文件:nnimport org.hibernate.Session;nimport org.hibernate.SessionFactory;nimport org.hibernate.Transaction;nimport org.hibernate.cfg.Configuration;nimport org.hibernate.service.ServiceRegistry;nimport org.hibernate.boot.registry.StandardServiceRegistryBuilder;nimport org.junit.After;nimport org.junit.Before;nimport org.junit.Test;nnimport java.util.Date;nn public class Studentstest n private SessionFactory sessionFactory;n private Session session;n private Transaction transaction;nn @Beforen public void init() n //创建配置对象n Configuration config = new Configuration().configure();n //创建服务注册对象n // ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();n //创建会话工厂对象n ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();n sessionFactory = config.buildSessionFactory(serviceRegistry);n //会话对象n session = sessionFactory.openSession();n //开启事务n transaction = session.beginTransaction();n nn @Aftern public void destory() n transaction.commit(); //提交事务n session.close(); //关闭会话n sessionFactory.close(); //关闭会话工厂n nn @Testn public void testSaveStudents() //增加n //生成学生对象n Students s = new Students();n s.setSname("POLY Ma");n s.setBirthday(new Date());n s.setAddress("Hong Kong");n s.setGender("M");n session.save(s); //保存对象进入数据库n n @Testn public void search()//查找n Students s=session.get(Students.class,1);//1 is primary keyn System.out.print(s);n n @Testn public void update()//修改n Students s=session.get(Students.class,2);//look onn s.setAddress("Hang Zhou");n session.update(s);n n @Testn public void delete()//删除n Students s=session.get(Students.class,1);n session.delete(s);n n nn映射文件:nnnnnn n n n n n n n n n n n n n n n n nn n nn主体:nimport java.util.Date;nn/**n * Created by tcxd on 2016/12/28.n */npublic class Students n private int sid; //学号n private String sname; //姓名n private String gender; //性别n private Date birthday; //出生日期n private String address; //地址nnn public Students() n nn public Students(int sid, String sname, String gender, Date birthday, String address) n this.sid = sid;n this.sname = sname;n this.gender = gender;n this.birthday = birthday;n this.address = address;n nn public int getSid() n return sid;n nn public void setSid(int sid) n this.sid = sid;n nn public String getSname() n return sname;n nn public void setSname(String sname) n this.sname = sname;n nn public String getGender() n return gender;n nn public void setGender(String gender) n this.gender = gender;n nn public Date getBirthday() n return birthday;n nn public void setBirthday(Date birthday) n this.birthday = birthday;n nn public void setAddress(String address) n this.address = address;n n public String getAddress() n return address;n nnnn @Overriden public String toString() n return "Students" +n "sid=" + sid +n ", sname='" + sname + '\'' +n ", gender='" + gender + '\'' +n ", birthday=" + birthday +n ", address=" + address +n '';n nn
Hibernate 框架配置文件
Hibernate 配置文件主要用于配置数据库连接和 Hibernate 运行时所需的各种属性Hibernate配置文件可以有两种格式: hibernate.properties hibernate.cfg.xml
Hibernate单个框架配置文件
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt; &amp;lt;!DOCTYPE hibernate-configuration PUBLIC &quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot; &quot;http://www.hibernate.org/dtd/hibernate...