我配置了两个applicationContext.xml(applicationContext_Elec.xml和applicationContext_OA.xml)连接两个数据库,我在web.xml里这么配置<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext_*.xml</param-value>
 </context-param>
这以我可以确定单独运行哪一个.xml文件都是可以访问数据库的,但是,就是两个放在一起,启动tomcat不会报错。进行action操作的时候报下面的错
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.a30elec.entity.Task; nested exception is org.hibernate.MappingException: Unknown entity: com.a30elec.entity.Task
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
at com.a30elec.daoimpl.TaskDaoImpl.findAgoTaskNo(TaskDaoImpl.java:195)
at com.a30elec.serviceimpl.TaskServiceImpl.findAgoTaskNo(TaskServiceImpl.java:61)
求大神指教ssh数据库nested

解决方案 »

  1.   

    classpath:applicationContext_*.xml
    这样写两个文件都会读的吧
      

  2.   

    看看你两个application.xml 里面是否有冲突 ,就是看有没有bean的名称相同。
    你说你配置了两个数据库 , 特别是看两个xml文件里面的sessionFactoryBean,或DataSource 的名字是否重复了。
      

  3.   

    应该两个文件都读了,我把其中一个文件改成错的。tomcat启动就会报错,说明这两个文件都读到了,可是为什么不能执行操作sql的方法呢,一执行就说找不到类
      

  4.   

    和web.xml配置无关,web.xml配置是对的
      

  5.   

    你配置的时候使用了通配符。 我没这样用过。
    不过,也可以精确的指定每一个文件。用逗号隔开就行了。类似下面这样。
     <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
         classpath*:applicationContext.xml,
    classpath*:springcxf.xml,  
    classpath*:jaxrs-https.xml,
    classpath*:springmvc.xml
        </param-value>
      </context-param>
      

  6.   

    报的错误是这个com.a30elec.entity.Task实体类没有配置映射啊
      

  7.   

    我看了,我这两个文件 的dataSource的名字是一样的。
      

  8.   


    我们公司不能上q 。 邮箱吧  [email protected]