加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java.lang.IllegalArgumentException:属性’transactionManager

发布时间:2020-12-15 01:30:59 所属栏目:大数据 来源:网络整理
导读:部署Spring应用程序时出现以下错误: java.lang.IllegalArgumentException:属性transactionManager是必需的 我在用: 操作系统:OSX Mountain Lion IDE:Springsource Tools Suite 3.1.0 春天:3.1.2 Hibernate:4.1.7 Java:1.6 webserver:vFabric tomcat

部署Spring应用程序时出现以下错误:

java.lang.IllegalArgumentException:属性’transactionManager’是必需的

我在用:
操作系统:OSX Mountain Lion
IDE:Springsource Tools Suite 3.1.0
春天:3.1.2
Hibernate:4.1.7
Java:1.6
webserver:vFabric tomcat v2.7

我有一些丢失的配置吗?我的pom.xml中的库是错误的吗?

部署日志:

Nov 3,2012 2:32:12 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /basicServer threw load() exception
java.lang.IllegalArgumentException: Property 'transactionManager' is required
    at org.springframework.transaction.interceptor.TransactionAspectSupport.afterPropertiesSet(TransactionAspectSupport.java:195)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
    at org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerByCGLIB$$8779d852.transactionInterceptor(

我的配置文件(ServicesConfiguration.java AppConfig.java)
ServicesConfiguration.java:

package com.bsches.basicServer.config;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import javax.sql.DataSource;

import org.hibernate.SessionFactory;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.bsches.basicServer.services.CustomerService;

import entities.Customer;

@Configuration
@EnableCaching
@EnableWebMvc
@EnableTransactionManagement
public class ServicesConfiguration {

    @Value("${jdbc.driverClassName}")
    private String driverClassName;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;

    @Value("${hibernate.dialect}")
    private String hibernateDialect;
    @Value("${hibernate.show_sql}")
    private String hibernateShowSql;
    @Value("${hibernate.hbm2ddl.auto}")
    private String hibernateHbm2ddlAuto;

    @Bean
    public CustomerService customerService() throws Exception {
        return new CustomerService(this.sessionFactory());
    }

    @Bean
    public SessionFactory sessionFactory() throws Exception {
        Properties props = new Properties();

        Map

AppConfig.java:

package com.bsches.basicServer.config;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource;

@Import({ServicesConfiguration.class})
@Configuration
public class AppConfig {
    @Bean
    public static PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer()
    {
        PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
        ppc.setLocation(new ClassPathResource("application.properties"));
        ppc.setIgnoreUnresolvablePlaceholders(true);
        return ppc;
    }

}

pom.xml中:


最佳答案

Spring: 3.1.2

你确定你使用的是Spring 3.1.2吗?

我查看了TransactionAspectSupport.afterPropertiesSet(TransactionAspectSupport.java:195)中的代码,从版本3.1.2开始没有异常抛出.

也许你的类路径上有2个不同的版本?

你的pom.xml建议3.1.0.RELEASE.

您最好只使用一个版本的Spring Framework.混合版本可能会出现奇怪的错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读