spring MVC注解 + hibernate +jpa配置 出错 具体如下

这个是错误 No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0

下面为XML配置文件

web.xml 导入hibernate

<filter>
    <filter-name>openEntityManagerInViewFilter</filter-name>
    <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>openEntityManagerInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

applicationContext.xml如下

<beans profile="production,development">
    <context:property-placeholder ignore-unresolvable="true"
        location="classpath*:properties/application.properties,
                  classpath*:properties/application.local.properties" />

    <!-- 数据源配置, 使用DBCP数据库连接池 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <!-- Connection Info -->
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@172.16.80.40:1521:ydRIS4T" />
        <property name="username" value="rim_uat" />
        <property name="password" value="password" />

        <!-- Connection Pooling Info -->
        <property name="maxActive" value="100" />
        <property name="maxIdle" value="20" />
        <property name="defaultAutoCommit" value="false" />
        <!-- 连接Idle一个小时后超时 -->
        <property name="timeBetweenEvictionRunsMillis" value="3600000" />
        <property name="minEvictableIdleTimeMillis" value="3600000" />
    </bean>
</beans>

<!-- Jpa Entity Manager 配置 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
    <property name="packagesToScan" value="com.rsxiao.test.entity"/>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
            <prop key="net.sf.ehcache.configurationResourceName">config/ehcache-hibernate-local.xml</prop>
            <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
        </props>
    </property>
</bean>

<bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />

<!-- Spring Data Jpa配置 -->
<jpa:repositories base-package="com.rsxiao.test" transaction-manager-ref="transactionManager"
    entity-manager-factory-ref="entityManagerFactory" />

<!-- Jpa 事务配置 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

Servlet.service() for servlet springServlet threw exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0
at org.springframework.beans.factory.BeanFactoryUtils.beanOfType(BeanFactoryUtils.java:394)
at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:111)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:194)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:170)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:128)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

mvc
0
suannai0314
鹳狸媛 楼主的这个问题解决了么?下边的答案能解决问题么?如果可以麻烦点击答案旁的√采纳哦~如果没有也可以将自己的答案贴上然后进行采纳的。
5 年多之前 回复

1个回答

No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0 ,把后面的错误日志也发出来看看! 前面的错误信息有可能是从架包底层报了来的。字面意思是bean 注入的name可能重复,可能有某bean未注入。
没用过jpa,但从你配置上来看,问题应该是出在applicationContext.xml下的jap配置,你可以找找它其他的配置方法再试试看。说不定问题就有可能得到解决!

参考帖:
http://www.iteye.com/topic/347882

1
xrs870709
IT小菜鸟_ 还什么都没有做 ,只是想先把他们先全部整合好
5 年多之前 回复
xrs870709
IT小菜鸟_ 就是整合spring+hibernate出错
5 年多之前 回复
a_liujian
a_jian org.springframework.beans.factory.NoSuchBeanDefinitionException; spring bean配置有误,未找到所需要的bean。先把spring+hibernate整合好吧
5 年多之前 回复
xrs870709
IT小菜鸟_ 错误贴在原文后面
5 年多之前 回复
xrs870709
IT小菜鸟_ 我还没有添加实体bean 目前还属于搭建环境阶段 entityManagerFactory这个没有重复
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring MVC注解 + hibernate +jpa配置 出错 具体如下
这个是错误 No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0rnrn下面为XML配置文件rnrnweb.xml 导入hibernaternrn rn openEntityManagerInViewFilterrn org.springframework.orm.jpa.support.OpenEntityManagerInViewFilterrn rn rn openEntityManagerInViewFilterrn /*rn rnrnrnapplicationContext.xml如下rnrnrn rn rnrn rn rn rn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.Oracle9Dialectrn org.hibernate.cache.ehcache.EhCacheRegionFactoryrn config/ehcache-hibernate-local.xmlrn org.hibernate.cfg.ImprovedNamingStrategyrn rn rn rnrn rnrn rn rnrn rn rn rn rnrn Servlet.service() for servlet springServlet threw exceptionrnorg.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0rn at org.springframework.beans.factory.BeanFactoryUtils.beanOfType(BeanFactoryUtils.java:394)rn at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:111)rn at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:194)rn at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:170)rn at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:128)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:619)rnrn
求spring mvc +jpa配置
求spring mvc +jpa配置
Hibernate JPA 注解一对多
本资源主要是希望能和大家交流一对多,多对多的映射关系,以便实现更好的开发,完善实体类与数据库的交流
JPA注解 和hibernate 建表
JPA注解创建数据库表 和hibernate.cfg.xml 建表
JPA -amp Hibernate 注解
JPA注解 1、@Entity(name="EntityName") 必须,name为可选,对应数据库中一的个表 2、@Table(name="",catalog="",schema="") 可选
jpa/hibernate继承注解
NULL 博文链接:https://cjnetwork.iteye.com/blog/974686
Hibernate之JPA注解
Hibernate之JPA注解
spring mvc 与JPA/Hibernate的整合示例
NULL 博文链接:https://ll-feng.iteye.com/blog/1908511
hibernate和spring MVC配置整合
hibernate和spring MVC配置整合
spring注解集成jpa
1,添加依赖jar包,注意spring和hibernate版本对应&amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.springframework.data&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;spring-data-jpa&amp;lt;/artifactId&amp;gt; &amp;lt...
java框架整合例子(spring、spring mvc、spring data jpa、hibernate)
java框架整合例子(spring、spring mvc、spring data jpa、hibernate)
spring mvc jpa
springMVC jpa整合实例,以及jpa延迟加载问题。
spring MVC JPA
spring MVC JPA + mysql 技术整合框架
Spring MVC 集成JPA
简单实用的Spring集成Jpa实例,20分钟教会你
spring mvc 3.2 配置出错
sprint mvc 配置文件rn[code=html]rnrnrn rn rn rn rn rn rn rn text/plain;charset=GBKrn rn rn rn rn rn rnrn rn rnrn rn rnrn rn rn rn rn rnrn[/code]rnweb.xml配置文件rn[code=html] rn appServletrn org.springframework.web.servlet.DispatcherServletrn rn contextConfigLocationrn classpath:servlet-context.xmlrn rn 1rn rnrn rn appServletrn /rn [/code]rn出错信息rn[code=text]ype Exception reportrnrnmessage Servlet.init() for servlet appServlet threw exceptionrnrndescription The server encountered an internal error that prevented it from fulfilling this request.rnrnexceptionrnrnjavax.servlet.ServletException: Servlet.init() for servlet appServlet threw exceptionrn org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)rn……rnroot causernrnorg.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [mvc-dispatcher-servlet.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@6b3fc7] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.rn…………)rnroot causernrnjavax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@6b3fc7] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.rn ……。rnroot causernrnjava.lang.IllegalArgumentException: No attributes are implementedrn org.apache.crimson.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:93)rn org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:99)rn org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)rn org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)rn org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)rn org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)rn org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)rn org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)rn org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)rn org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)rn org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)rn org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)rn org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)rn org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)rn org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)rn org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)rn org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)rn org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)rn org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)rn org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)rn javax.servlet.GenericServlet.init(GenericServlet.java:160)rn org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)rn org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)rn org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)rn org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)rn org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)rn org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)rn org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)rn java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)rn java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)rn java.lang.Thread.run(Thread.java:619)[/code]
spring data jpa + spring mvc
NULL 博文链接:https://illiqiang.iteye.com/blog/2029992
Spring mvc + jpa 配置,两个案例
Spring mvc + jpa +mysql5.6 配置,项目可运行。其中有两个案例,包含增删改查,复合主键开发 查询列表中,下拉列表显示名称所采用方式数据量大的时候存在问题,建议使用多表关联的方式。适合菜鸟学习。
Hibernate开发讲义JPA注解
Hibernate开发讲义JPA注解.ppt
hibernate和jpa注解关联总结
[size=x-large]用hibernate和jpa annotation 大概一年多了,今天闲来无事,对他们关联关系元数据写法做一个总结。[/size] [size=x-large]1.一对一主键关联[/size] [size=large] 这个在实际项目中用的比较少,大部分是通过用外键做关联的,这里用用户和手机号举个例子,用户和手机号是一对一的关系,代码如下:[/size] Use...
Hibernate单向一对多JPA注解
首先新建三张表:t_user,t_user_role_relation,t_role CREATE TABLE t_user ( uid INT NOT NULL AUTO_INCREMENT COMMENT 'user id', uname VARCHAR(32) NOT NULL COMMENT 'user name, real chinese name ', mobile VARC
Hibernate使用JPA注解代码
Hibernate5.1.fianl整合JPA注解方式异常:persistence.Table.indexes()[Ljavax/persistence/Index;
spring4.2,spring mvc,spring data,jpa,hibernate的程序构架
spring4.2,spring mvc,spring data,jpa,hibernate的程序构架
Spring MVC Java配置有关的类/注解
缺省配置类 : WebMvcConfigurationSupport – 提供缺省的SpringMVC配置 定义如下bean : RequestMappingHandlerMapping requestMappingHandlerMapping() PathMatcher mvcPathMatcher() UrlPathHelper mvcUrlPathHelper() ContentNego...
Spring MVC 注解及XML双重配置
平常使用Spring 导出 WebService时,为了能在Spring MVC中既能使用注解进行Controller配置及用XML配置,如下: Java 代码 另外还要加入DefaultAnnotationHandlerMapping, 不然会被 XML的映射覆盖! Java代码 ...
使用spring jpa出错
org.springframework.dao.InvalidDataAccessApiUsageException: interface org.springframework.orm.jpa.EntityManagerProxy is not visible from class loader; nested exception is java.lang.IllegalArgumentException: interface org.springframework.orm.jpa.EntityManagerProxy is not visible from class loaderrn at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:269)rn at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120)rn at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212)rn at org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)rn at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:190)rn at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:152)rn at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:299)rn at com.ibm.dw.spring2.dao.EmployeeDAO.findByEmployeeLastName(EmployeeDAO.java:29)rn at test.ibm.dw.spring2.test.EmployeeServiceIntegrationTest.testModifyEmployee(EmployeeServiceIntegrationTest.java:47)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 junit.framework.TestCase.runTest(TestCase.java:154)rn at junit.framework.TestCase.runBare(TestCase.java:127)rn at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)rn at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:47)rn at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:115)rn at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:180)rn at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:153)rn at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:111)rn at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:174)rn at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:254)rn at junit.framework.TestResult$1.protect(TestResult.java:106)rn at junit.framework.TestResult.runProtected(TestResult.java:124)rn at junit.framework.TestResult.run(TestResult.java:109)rn at junit.framework.TestCase.run(TestCase.java:118)rn at junit.framework.TestSuite.runTest(TestSuite.java:208)rn at junit.framework.TestSuite.run(TestSuite.java:203)rn at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)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:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnCaused by: java.lang.IllegalArgumentException: interface org.springframework.orm.jpa.EntityManagerProxy is not visible from class loaderrn at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)rn at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)rn at org.springframework.orm.jpa.JpaTemplate.createEntityManagerProxy(JpaTemplate.java:211)rn at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:184)rn ... 30 morernrn
JPA hibernate的配置
本人对hibernate不是很熟,求轻拍rn用的是androidpn做服务器,apn底层是用的hibernate,现在我想加入新的实体对象,同时实现相关的数据库读写,但问题也是出现在getHibernateTemplate().update上,会抛出java.lang.NullPointerException空指针异常,对应的是在查询对象的时候即getHibernateTemplate().get(CallOrder.class, id)正确无误,所以怀疑是新加的实体对象在配置的时候没有配置正确,apn的配置其实比较简单,只有两个文件,其中一个是spring-config.xml,以下是片段rn[code=html]rn rn rnrn rn rn rn rnrn rn rn rnrn rn rn rnrn rn rn rn rn rn rnrn rn rn rnrn rn rn rn rn rn [/code]rnrn求指点!
Spring:基于注解的Spring MVC(下)
上一篇文章《Spring:基于注解的Spring MVC(上)》,讲了Spring MVC环境搭建、@RequestMapping以及参数绑定,这是Spring MVC中最基础也是最重要的内容,本篇文章继续讲讲Spring MVC中其余的知识点,先从Model开始。 前一篇文章比较详细地解读了数据从页面请求到服务器后台的一些细节,那么下一个要解决的问题就是数据如何从后台再次传回前台,答案就是这里
Spring MVC的常用注解
Spring MVC常用注解案例源代码
注解的spring MVC 详解
该文档时基于注解的当前流行的SpringMVC框架,涵盖了springMVC常用的注解的使用方法!以及文件的配置,和案例!
spring mvc注解例子
   弃用了struts,用spring mvc框架做了几个项目,感觉都不错,而且使用了注解方式,可以省掉一大堆配置文件。本文主要介绍使用注解方式配置的spring mvc,之前写的spring3.0 mvc和rest小例子没有介绍到数据层的内容,现在这一篇补上。下面开始贴代码。 文中用的框架版本:spring 3,hibernate 3,没有的,自己上网下。 web.xml配置: &amp;...
spring mvc(基于注解)
  web.xml 配置: &amp;lt;servlet&amp;gt; &amp;lt;servlet-name&amp;gt;dispatcher&amp;lt;/servlet-name&amp;gt; &amp;lt;servlet-class&amp;gt;org.springframework.web.servlet.DispatcherServlet&amp;lt;/servlet-class&amp;gt; &amp;lt;init-...
Spring MVC注解类型
Spring MVC注解类型 Controller和RequestMapping注释类型是SpringMVC API最重要的两个注解类型。 1.Controller(用于指示Spring类的实例是一个控制器) Spring使用扫描机制来找到应用程序中所有基于注解的控制器类。为了保证Spring能找到你的控制器,需要完成两件事。 首先,需要在Spring MVC的配置文件中声明Spring-...
spring mvc注解解释
@Controller:用于标识是处理器类; @RequestMapping:请求到处理器功能方法的映射规则; @RequestParam:请求参数到处理器功能处理方法的方法参数上的绑定; @ModelAttribute:请求参数到命令对象的绑定; @SessionAttributes:用于声明session 级别存储的属性,放置在处理器类上,通常列出模型属性(如 @ModelAttr...
spring mvc 用到的注解
在实际项目中很少用全部用配置文件到注册Bean,映射MVC等,全用注解,这样可以减少很多配置文件,节约开发时间。 spring mvc 用到的注解:所有注解使用场合必须开启spring 组件扫描 [code=&quot;xml&quot;] [/code] 在Action中用到的 @Controller--此注解用于标记在spring中由Bean工厂管理Action,并标明此类为MVC中的Control...
Spring MVC 常用注解
Spring mvc常用4个基本注解 @Component、@Repository 、@Service、@Controller @Controller 控制层 ,通常我们所说的action层 @Service 业务逻辑层,通常我们所说的service层或者manger层 @Repository 持久层,通常我们所说的Dao层 @Component 组件,书面意思就是我们不知道在哪一层时使...
spring mvc 注解实例
spring mvc 注解 拦截器 对一个数据库表进行了增删改查操作 ,初学spring mvc框架的 可以参考 代码下载直接可以运行!~~
spring mvc注解环境搭建
项目结构: -------------------------------------- web.xml xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/we
Spring MVC搭建环境与 注解
搭建spring MVC环境: 1.创建web项目 2. 加入jar包,新建文件夹:WEB-INF/jsp, 并新建MyJsp.jsp页面 3.配置web.xml文件 xmlns="http://java.sun.com/xml/ns/javaee" x mlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xs
Spring MVC常用注解
常用注解 Controller 注解一个类表示控制器,Spring MVC会自动扫描标注了这个注解的类。 RequestMapping 请求路径映射,可以标注类,也可以是方法,可以指定请求类型,默认不指定为全部接收。 RequestParam 放在参数前,表示只能接收参数a=b格式的数据,即Content-Type为application/x-www-form-urlenc
Spring MVC注解数据绑定
1.@RequestParam@Controller @RequestMapping(&quot;/example8/paramController&quot;) public class ParamController { @RequestMapping(&quot;/bindParam.htm&quot;) public String bindParam(@RequestParam(value=&quot;paramAge&quot;,requi...