V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
charles1256
V2EX  ›  问与答

求 sqlserver 问题解决

  •  
  •   charles1256 · 2019-02-08 23:22:51 +08:00 · 1239 次点击
    这是一个创建于 2108 天前的主题,其中的信息可能已经有所发展或是发生改变。

    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.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 org.hibernate.MappingException: entity class not found: com.model.TAdmin Caused by: org.hibernate.MappingException: entity class not found: com.model.TAdmin at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99) at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168) at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.ClassNotFoundException: com.model.TAdmin at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100) at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96) ... 36 more 二月 08, 2019 11:08:49 下午 org.apache.catalina.core.StandardContext startInternal 严重: Error listenerStart 二月 08, 2019 11:08:49 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/che] startup failed due to previous errors</init></init></init></init>

    1 条回复    2019-02-08 23:37:49 +08:00
    charles1256
        1
    charles1256  
    OP
       2019-02-08 23:37:49 +08:00
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
    value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
    </property>
    <property name="url"
    value="jdbc:microsoft:sqlserver://192.168.1.9:1433;databaseName=db_che">
    </property>
    <property name="username" value="sa"></property>
    <property name="password" value="sa"></property>
    </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.SQLServerDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>com/model/TAdmin.hbm.xml</value>
    <value>com/model/TSiji.hbm.xml</value>
    <value>com/model/TChe.hbm.xml</value>
    <value>com/model/TChuche.hbm.xml</value>
    </list>
    </property>
    </bean>




    <!-- 后台的登录 -->
    <bean id="loginService" class="com.service.loginService">
    <property name="adminDAO">
    <ref bean="TAdminDAO" />
    </property>
    </bean>

    <bean id="dwrService" class="com.service.DwrService">
    </bean>




    <bean id="TAdminDAO" class="com.dao.TAdminDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="adminAction" class="com.action.adminAction" scope="prototype">
    <property name="adminDAO">
    <ref bean="TAdminDAO" />
    </property>
    </bean>




    <bean id="TSijiDAO" class="com.dao.TSijiDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="sijiAction" class="com.action.sijiAction" scope="prototype">
    <property name="sijiDAO">
    <ref bean="TSijiDAO" />
    </property>
    </bean>



    <bean id="TCheDAO" class="com.dao.TCheDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="cheAction" class="com.action.cheAction" scope="prototype">
    <property name="cheDAO">
    <ref bean="TCheDAO" />
    </property>
    <property name="sijiDAO">
    <ref bean="TSijiDAO" />
    </property>
    </bean>




    <bean id="TChucheDAO" class="com.dao.TChucheDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="chucheAction" class="com.action.chucheAction" scope="prototype">
    <property name="cheDAO">
    <ref bean="TCheDAO" />
    </property>
    <property name="chucheDAO">
    <ref bean="TChucheDAO" />
    </property>
    </bean>
    </beans>

    已经用可视化软件连接上了 sqlserver
    已经增加了一个 lib
    sqljdbc4.jar (已经在 java build path 添加 jar,编译器是 myeclipse2014 )
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2194 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 01:28 · PVG 09:28 · LAX 17:28 · JFK 20:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.