spring+springmvc+openjpa的逆向工程整合出错
来源:互联网 发布:2017网络项目 编辑:程序博客网 时间:2024/04/30 11:11
整合出错了,希望大神们给我点帮助谢谢
spring-openjpa.xml:
<bean id="entityManagerFactory"class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"><property name="persistenceUnitName" value="SpringMvcTest" /><!-- <property name="persistenceXmlLocation" value="classpath:openjpa-persistence.xml" /> --></bean><bean id="transactionManager"class="org.springframework.orm.jpa.JpaTransactionManager"><property name="entityManagerFactory" ref="entityManagerFactory" /></bean><tx:annotation-driven transaction-manager="transactionManager" /><bean id="userService" class="com.mvc.service.impl.UserServiceImpl"></bean></beans>
persistence.xml:
<persistence-unit name="SpringMvcTest" transaction-type="RESOURCE_LOCAL"><provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider><class>com.mvc.beans.User</class><properties><!-- <property name="openjpa.ConnectionProperties" value="DriverClassName=com.mysql.jdbc.Driver, Url=jdbc:mysql://127.0.0.1:3306/mvctest, MaxActive=100, MaxWait=10000, TestOnBorrow=true,Username=root,Password=root" /> --> <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" /> <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/mvctest" /> <property name="openjpa.ConnectionUserName" value="root" /> <property name="openjpa.ConnectionPassword" value="root" /> <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource" /><property name="openjpa.RuntimeUnenhancedClasses" value="supported" /><!-- 允许多线程访问default broker--><property name="openjpa.Multithreaded" value="true" /> <!-- 自动建表语句 --><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <!-- 初始加载根目录下所有以spring开头和.xml结尾的文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring*.xml</param-value> </context-param> <!-- 配置映射的springmvc配置文件 --> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- 添加spring框架的监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- servletname的mapping --> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.jz</url-pattern> </servlet-mapping> <!-- <context-param> <param-name>contextConfigLocation</param-name> 应用上下文配置文件 <param-value>classpath:spring-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 配置spring核心servlet <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> url-pattern配置为/,不带文件后缀,会造成其它静态文件(js,css等)不能访问。如配为*.do,则不影响静态文件的访问 <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.jz</url-pattern> </servlet-mapping> --> <!-- 配置log4j配置文件的路径,可以是xml或 properties文件(此参数必须配)--><context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:log4j.properties</param-value></context-param><!-- 每隔多少毫秒扫描一下配置文件的变化(此参数可选配)<context-param> <param-name>log4jRefreshInterval</param-name> <param-value>60000</param-value></context-param>spring框架默认定义webAppRootKey的值为webapp.root,若不配此参数默认值就是webapp.root(因此,此参数可选配)<context-param> <param-name>webAppRootKey</param-name> <param-value>home</param-value></context-param> --><!-- 创建log4j的监听器 --><listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener> </web-app>
spring-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射--> <mvc:annotation-driven /> <!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean --> <context:component-scan base-package="com.mvc.controller" /> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/view/" p:suffix=".jsp" /> </beans>
junit测试类:
public class UserTestJunit {private static UserService userService;@BeforeClasspublic static void setUpBeforeClass() throws Exception {try {ApplicationContext context = new ClassPathXmlApplicationContext("spring-openjpa.xml");userService = (UserService) context.getBean("userService");} catch (Exception e) {e.printStackTrace();}}@Testpublic void test() {User user = new User();user.setUserName("aa");user.setPassWord("123456");userService.save(user);}}
报错信息:
- spring+springmvc+openjpa的逆向工程整合出错
- mybatis和Spring的整合,逆向工程
- Mybatis 03 整合Spring+逆向工程
- spring整合mybatis逆向工程+PageHelper插件
- spring-springmvc-mybatis-maven整合的简单工程
- MyBatis学习七:spring和MyBatis整合、逆向工程
- spring+springmvc+mybatis(3)--逆向工程自动生成代码
- Spring+SpringMVC+MyBatis的整合
- SpringMVC+Hibernate+Spring的整合
- spring、springmvc、hibernate的整合
- 基于MAVEN的SSM(SPRING,SPRINGMVC,MYBATIS)整合的WEB工程
- SpringMVC+Spring+Mybatis三大框架的整合流程(基于maven工程)
- Mybatis(3、延迟加载、查询缓存、与ehcache整合、逆向工程、与spring整合)
- SpringMVC-整合Spring整合
- maven工程建立和SSM(springMVC+spring+mybatis)整合
- 逆向工程重复生成代码导致出错
- mybatis 高级映射和spring整合之逆向工程(7)
- MyBatis入门第4天--MyBatis与Spring整合及逆向工程
- android back键处理
- 蛇形线走线注意要点
- Discuz论坛防止广告机的方法
- 关于设置X-UA-Compatible来设置IE浏览器兼容模式时无效问题
- Win7上配置Cocos2dx开发环境
- spring+springmvc+openjpa的逆向工程整合出错
- Android中Back键与Home键的区别
- 第五周上级项目三
- VB中的 命名参数
- (转)内联函数
- 2013年3月23号竞赛题目一 平衡负载
- 黑马程序员————学习日记【2】 【Java编程基础1】
- Thinking in Java之接口回调
- Uva 10048 - Audiophobia