spring+springmvc+openjpa的逆向工程整合出错
2013-04-03 12:26
176 查看
整合出错了,希望大神们给我点帮助谢谢
spring-openjpa.xml:
persistence.xml:
web.xml:
spring-servlet.xml:
junit测试类:
报错信息:
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; @BeforeClass public static void setUpBeforeClass() throws Exception { try { ApplicationContext context = new ClassPathXmlApplicationContext("spring-openjpa.xml"); userService = (UserService) context.getBean("userService"); } catch (Exception e) { e.printStackTrace(); } } @Test public void test() { User user = new User(); user.setUserName("aa"); user.setPassWord("123456"); userService.save(user); } }
报错信息:
相关文章推荐
- Spring+SpringMVC+MyBatis深入学习及搭建(十)——MyBatis逆向工程
- IDEA17用Maven创建SpringMVC+Spring+Mybatis工程及整合配置与实例
- Maven 工程整合 Spring mvc + Mybatis +Velocity
- JAVAWEB开发之mybatis详解(二)——高级映射、查询缓存、mybatis与Spring整合以及懒加载的配置和逆向工程
- 浅析Spring和MyBatis整合及逆向工程
- springboot整合mybatis逆向工程
- [置顶]springmvc+mybatis,在mybatis逆向工程的基础上使用模板自动生成controller层代码
- mybatis 高级映射和spring整合之逆向工程(7)
- Mybatis(3、延迟加载、查询缓存、与ehcache整合、逆向工程、与spring整合)
- mybatis 高级映射和spring整合之逆向工程(7)
- JAVAWEB开发之mybatis详解(二)——高级映射、查询缓存、mybatis与Spring整合以及懒加载的配置和逆向工程
- 框架 day66 Mybatis(关联查询映射(1对1/多),延迟加载,一级/二级缓存,与spring整合,逆向工程)
- spring+springmvc+mybatis(3)--逆向工程自动生成代码
- 使用IDEA基于Maven搭建多模块聚合工程(springmvc+spring+mybatis整合)
- SpringBoot整合MyBatis逆向工程及 MyBatis通用Mapper实例详解
- Spring+SpringMVC+MyBatis深入学习及搭建(十)——MyBatis逆向工程
- spring整合mybatis逆向工程+PageHelper插件
- MyBatis入门第4天--MyBatis与Spring整合及逆向工程
- dubbo zookeeper spring mvc简单整合的工程例子demo
- 使用IDEA基于Maven搭建多模块聚合工程(springmvc+spring+mybatis整合)