简体   繁体   English

我无法运行Spring和MyBatis应用程序

[英]I can not run the Spring and MyBatis application

When you try to run the falls with the error: 当您尝试运行带有错误的瀑布时:

org.springframework.beans.factory.BeanCreationException: Error creating bean  with name 'sqlSessionFactory' defined in class path resource [application- context.xml]: Error setting property values; nested exception is  org.springframework.beans.PropertyBatchUpdateException; nested  PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy

application-context.xml:

<?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.xsd">

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:db.properties</value>
        </list>
    </property>
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${db.driver}"/>
    <property name="url" value="${db.url}"/>
    <property name="username" value="${db.user}"/>
    <property name="password" value="${db.password}"/>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="typeAliasesPackage" value="com.rest.service.entity" />
</bean>

<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="com.rest.service.mapping.UserMapper" />
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

I do not understand what is wrong, do these instructions: http://www.mybatis.org/spring/getting-started.html 我不明白这是什么问题,请按照以下说明进行操作: http : //www.mybatis.org/spring/getting-started.html

The context is initialized: public class ApplicationInitializer implements WebApplicationInitializer { 上下文已初始化:公共类ApplicationInitializer实现WebApplicationInitializer {

private static final String DISPATCHER = "dispatcher";


public void onStartup(ServletContext servletContext) throws ServletException {
    XmlWebApplicationContext appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:application-context.xml");
    ServletRegistration.Dynamic dispatcher =
            servletContext.addServlet(DISPATCHER, new DispatcherServlet(appContext));
    dispatcher.addMapping("/");
    dispatcher.setLoadOnStartup(1);
   }
}

With what may be related problem? 与什么可能相关的问题?

I just added it in my pom.xml and it is work: 我刚刚将其添加到pom.xml ,并且可以正常工作:

   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 切换到myBatis时,我可以将iBatis和Mybatis保留在同一个应用程序中吗? - Can I keep iBatis and Mybatis in the same application while switching to myBatis? 我可以在Spring Boot应用程序中运行长任务吗? - Can I run long tasks in a Spring Boot application? 如何在端口 80 上运行 Spring Boot 应用程序 - How can I run a Spring Boot application on port 80 我可以运行一个空的 spring 引导应用程序而不会出现错误吗? - Can I run an empty spring boot application without getting an Error? 如何在 Spring Boot 应用程序的 application.properties 文件中设置 MyBatis 配置属性? - How do I set MyBatis configuration properties in an application.properties file in a Spring Boot application? Mybatis ResultHandler with spring boot 无法运行 - Mybatis ResultHandler with spring boot could not run 从数据库将映像加载到Application Context Spring中。 我使用mybatis api - Load Image into Application Context Spring from database. I use mybatis api 使用&#39;spring boot + mybatis&#39;使用&#39;spring Application&#39;创建的项目可以启动,如果您使用外部tomcat,则dao错误注入 - Use 'spring boot + mybatis' projects created using 'spring Application' can start, if you use an external tomcat, dao error injection 我可以从另一个 spring boot 应用程序中编译并运行 spring boot jar 吗? - Can I compile and run a spring boot jar from inside another spring boot application? 春季3 + MyBatis 3 - Spring 3 + MyBatis 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM