SpringMvc+Mybatis ServiceBean实例化了两次

贺蜜峰 发布于 2015/05/22 11:27
阅读 4K+
收藏 0

  问题描述

同样的的配置,我在window上部署没有问题,在Eclipse上调试也没有问题,但在centos+apache+mod_jk+tomcat就出现问题,(centos+apache+mod_jk+tomcat配置没有错误,我已经同一款centos构建了两个项目)

  配置如下:


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_2_5.xsd" version="2.5">
	<display-name>mltd-cmis</display-name>

	<!-- 编码 -->
	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<servlet-name>SpringMVC</servlet-name>
	</filter-mapping>
	<!-- 静态资源 -->
	<filter>
		<filter-name>compressingFilter</filter-name>
		<filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>compressingFilter</filter-name>
		<url-pattern>*.css</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>compressingFilter</filter-name>
		<url-pattern>*.js</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>compressingFilter</filter-name>
		<url-pattern>*.html</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>compressingFilter</filter-name>
		<servlet-name>SpringMVC</servlet-name>
	</filter-mapping>

	<!-- 指定Spring Bean的配置文件所在目录。默认配置在WEB-INF目录下 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:/config/applicationContext.xml</param-value>
	</context-param>
	
	<!-- log4j 配置 -->
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/config/log4j.properties</param-value>
	</context-param>
	<context-param>
		<param-name>log4jRefreshInterval</param-name>
		<param-value>600000</param-value>
	</context-param>
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>mltd_sys.root</param-value>
	</context-param>

	
	<!-- Spring MVC配置 -->
	<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*:/config/applicationContext-webmvc.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>SpringMVC</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

	<!-- Log4j配置 -->
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>
	<!-- Spring配置 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<session-config>
		<session-timeout>30</session-timeout>
	</session-config>
</web-app>



applicationContext.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" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
        

	<!-- 加载配置文件 -->
	<context:property-placeholder
		file-encoding="utf-8" location="classpath:/config/app.properties" />

	<!-- 自动扫描包 -->
	<context:component-scan base-package="com.bee">
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
		<!-- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /> -->
	</context:component-scan>

	<!-- BoneCP 数据源 -->
	<!-- destroy-method:销毁时调用方法 -->
	<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
		destroy-method="close">
		<!-- 数据库驱动 -->
		<property name="driverClass" value="${jdbc.driver}" />
		<!-- 连接池URL -->
		<property name="jdbcUrl" value="${jdbc.url}" />
		<!-- 数据库用户名 -->
		<property name="username" value="${jdbc.username}" />
		<!-- 数据库密码 -->
		<property name="password" value="${jdbc.password}" />
		<!-- 检查数据库连接池中空闲连接的间隔时间,单位是分,默认值:240,如果要取消则设置为0 -->
		<property name="idleConnectionTestPeriodInMinutes"
			value="${bonecp.idle_connection_test_period_in_minutes}" />
		<!-- 连接池中未使用的链接最大存活时间,单位是分,默认值:60,如果要永远存活设置为0 -->
		<property name="idleMaxAgeInMinutes" value="${bonecp.idle_max_age_in_minutes}" />
		<!-- 每个分区最大的连接数 -->
		<property name="maxConnectionsPerPartition" value="${bonecp.max_connections_per_partition}" />
		<!-- 每个分区最小的连接数 -->
		<property name="minConnectionsPerPartition" value="${bonecp.min_connections_per_partition}" />
		<!-- 分区数 ,默认值2,最小1,推荐3-4,视应用而定 -->
		<property name="partitionCount" value="${bonecp.partition_count}" />
		<!-- 每次去拿数据库连接的时候一次性要拿几个,默认值:2 -->
		<property name="acquireIncrement" value="${bonecp.acquire_increment}" />
		<!-- 缓存prepared statements的大小,默认值:0 -->
		<property name="statementsCacheSize" value="${bonecp.statements_cache_size}" />
		<!-- 每个分区释放链接助理进程的数量,默认值:3,除非你的一个数据库连接的时间内做了很多工作,不然过多的助理进程会影响你的性能 已过时 -->
		<!-- <property name="releaseHelperThreads" value="${bonecp.release_helper_threads}" 
			/> -->
		<!-- 获取连接的时候最大的等待时间,默认值为:Long.MAX_VALUE -->
		<property name="connectionTimeoutInMs" value="${bonecp.connection_timeout_in_ms}" />
	</bean>

	<!-- 配置通用mybatis mapper -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mapperLocations">
			<array>
				<!-- <value>classpath:mapper/com/bee/**/mapper/*.xml</value> -->
				<value>classpath:mapper/**/*.xml</value>
			</array>
		</property>
		<property name="typeAliasesPackage" value="com.isea533.mybatis.model" />
		<property name="plugins">
			<array>
				<bean class="com.github.pagehelper.PageHelper">
					<property name="properties">
						<value>
							dialect=hsqldb
							reasonable=true
						</value>
					</property>
				</bean>
				<bean class="com.github.abel533.mapperhelper.MapperInterceptor">
					<property name="properties">
						<!-- 属性一行一个,具体属性参考mybatis-config.xml中的属性 -->
						<value>
							mappers=com.github.abel533.mapper.Mapper
						</value>
					</property>
				</bean>
			</array>
		</property>
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.bee.**.mapper" />
	</bean>

	<bean id="entityMapper" class="com.github.abel533.entity.EntityMapper"
		scope="prototype">
		<constructor-arg ref="commonMapper" />
	</bean>

	<bean id="sqlMapper" class="com.github.abel533.sql.SqlMapper"
		scope="prototype">
		<constructor-arg ref="sqlSession" />
	</bean>

	<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"
		scope="prototype">
		<constructor-arg index="0" ref="sqlSessionFactory" />
	</bean>

	<aop:aspectj-autoproxy />

	<aop:config>
		<aop:pointcut id="appService"
			expression="execution(* com.bee.**.service..*Service*.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="appService" />
	</aop:config>

	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="select*" read-only="true" />
			<tx:method name="find*" read-only="true" />
			<tx:method name="get*" read-only="true" />
			<tx:method name="*" />
		</tx:attributes>
	</tx:advice>

	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
</beans>



applicationContext-webmvc.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" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.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.xsd">


	<!-- 加载配置文件 -->
	<context:property-placeholder
		file-encoding="utf-8" location="classpath:/config/app.properties" />

	<!-- 扫描组件(扫描所有需要注入的组件) -->
	<context:component-scan base-package="com.bee.**.controller" use-default-filters="false">
		<!-- 例外 -->
		<!-- type:类型 -->
		<!-- expression:表达式 -->
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
		<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> -->
	</context:component-scan>
	
	 <!--  annotation默认的方法映射适配器 -->    
    <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />     
    <bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

	<!-- 静态资源访问 -->
	<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
	<mvc:resources mapping="/assets/**" location="/assets/" />
	<mvc:resources mapping="/statics/**" location="/statics/" />

	<!-- 拦截器 -->
	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/assets/**" />
			<mvc:exclude-mapping path="/statics/**" />
			<mvc:exclude-mapping path="/logout*" />
			<mvc:exclude-mapping path="/login*" />
			<bean id="adminHandlerInterceptor" class="com.bee.cmis.interceptor.AdminHandlerInterceptor"></bean>
		</mvc:interceptor>
	</mvc:interceptors>
	<!-- 默认注解映射支持 -->
	<mvc:annotation-driven>
		<mvc:message-converters register-defaults="true">
			<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
			<bean id="fastJsonHttpMessageConverter"
				class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
				<property name="supportedMediaTypes">
					<list>
						<value>text/html;charset=UTF-8</value>
					</list>
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>

	<!-- <bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="cacheSeconds" value="0" />
		<property name="messageConverters">
			<list>
				加入Jackson json库
				<bean
					class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean>
			</list>
		</property>
	</bean>

	避免IE在ajax请求时,返回json出现下载
	<bean id="jacksonMessageConverter"
		class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/html;charset=UTF-8</value>
			</list>
		</property>
	</bean> -->

	<!-- freemarker 配置 -->
	<bean
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="templateLoaderPath" value="${template.loader_path}" />
		<property name="defaultEncoding" value="UTF-8" />

		<!-- Freemarker设置 -->
		<property name="freemarkerSettings">
			<props>
				<prop key="defaultEncoding">${template.encoding}</prop>
				<prop key="url_escaping_charset">${url_escaping_charset}</prop>
				<prop key="locale">${locale}</prop>
				<!-- <prop key="template_update_delay">3000</prop> -->
				<prop key="tag_syntax">auto_detect</prop>
				<prop key="whitespace_stripping">true</prop>
				<prop key="classic_compatible">true</prop>
				<prop key="number_format">${template.number_format}</prop>
				<prop key="boolean_format">${template.boolean_format}</prop>
				<prop key="datetime_format">${template.datetime_format}</prop>
				<prop key="date_format">${template.date_format}</prop>
				<prop key="time_format">${template.time_format}</prop>
				<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
			</props>
		</property>

		<!-- Freemarker变量 -->
		<property name="freemarkerVariables">
			<map>
				<!-- 系统信息 -->
				<entry key="sysname" value="${sys.name}" />
				<entry key="sysversion" value="${sys.version}" />
				<!-- 公司信息 -->
				<entry key="cname" value="${company.name}" />
			</map>
		</property>
	</bean>

	<!-- freemarker视图解析器 -->
	<bean
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<property name="suffix" value="${template.suffix}" />
		<property name="contentType" value="text/html;charset=UTF-8" />
		<!-- 此变量值为pageContext.request, 页面使用方法:rc.contextPath -->
		<property name="requestContextAttribute" value="request" />
	</bean>

</beans>



pom.xml配置如下(采用Mavan构建项目)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.bee</groupId>
	<artifactId>mltd-system</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>mltd-system Maven Webapp</name>
	<url>http://maven.apache.org</url>

	<profiles>

	</profiles>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<!-- MyBatis Generator -->
		<!-- Java接口和实体类 -->
		<targetJavaProject>${basedir}/src/main/java</targetJavaProject>
		<targetMapperPackage>com.bee.cmis.borrowing.mapper</targetMapperPackage>
		<targetModelPackage>com.bee.cmis.borrowing.entity</targetModelPackage>
		<!-- XML生成路径 -->
		<targetResourcesProject>${basedir}/src/main/resources</targetResourcesProject>
		<targetXMLPackage>mapper.com.bee.cmis.borrowing.mapper</targetXMLPackage>
		<!-- 编译jdk版本 -->
		<jdk.version>1.7</jdk.version>
		<!-- 依赖版本 -->
		<junit.version>4.12</junit.version>
		<servlet-api.version>2.5</servlet-api.version>
		<slf4j.version>1.5.8</slf4j.version>
		<spring.version>4.1.6.RELEASE</spring.version>
		<freemarker.version>2.3.22</freemarker.version>
		<fastjson.version>1.2.5</fastjson.version>
		<jackson-databind.version>2.5.3</jackson-databind.version>
		<bonecp.version>0.8.0.RELEASE</bonecp.version>
		<mysql.version>5.1.29</mysql.version>
		<mybatis.version>3.2.8</mybatis.version>
		<mybatis-spring.version>1.2.2</mybatis-spring.version>
		<pagehelper.version>3.7.2</pagehelper.version>
		<mapper.version>2.3.2</mapper.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>${servlet-api.version}</version>
			<scope>provided</scope>
		</dependency>

		<!-- srping-webmvc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
			<exclusions>
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!-- spring-jdbc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- spring-context-support -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<!-- aspectj -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>1.8.5</version>
		</dependency>

		<!-- spring freemarker -->
		<dependency>
			<groupId>org.freemarker</groupId>
			<artifactId>freemarker</artifactId>
			<version>${freemarker.version}</version>
		</dependency>

		<!-- json解析器 -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson-databind.version}</version>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>${fastjson.version}</version>
		</dependency>

		<!-- common-loggoing to slf4j to log4j -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j.version}</version>
		</dependency>

		<!-- mysql驱动 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql.version}</version>
		</dependency>

		<!-- 连接池 -->
		<dependency>
			<groupId>com.jolbox</groupId>
			<artifactId>bonecp</artifactId>
			<version>${bonecp.version}</version>
		</dependency>

		<dependency>
			<groupId>com.jolbox</groupId>
			<artifactId>bonecp-spring</artifactId>
			<version>${bonecp.version}</version>
		</dependency>

		<!-- Mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>${mybatis.version}</version>
		</dependency>

		<!-- Spring Mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>${mybatis-spring.version}</version>
		</dependency>

		<!-- Mybatis 分页 -->
		<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper</artifactId>
			<version>${pagehelper.version}</version>
		</dependency>

		<!-- Mybatis 通用Mapper -->
		<dependency>
			<groupId>com.github.abel533</groupId>
			<artifactId>mapper</artifactId>
			<version>${mapper.version}</version>
			<exclusions>
				<exclusion>
					<artifactId>commons-logging</artifactId>
					<groupId>commons-logging</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<!-- Mybatis 生成代码 -->
		<dependency>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.3.2</version>
			<scope>provided</scope>
		</dependency>

		<!-- commons-lang 工具包 -->
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.4</version>
		</dependency>

		<!-- RSA加密 -->
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
			<version>1.10</version>
		</dependency>
		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcpg-jdk15on</artifactId>
			<version>1.52</version>
		</dependency>

		<!-- 静态资源过滤 -->
		<dependency>
			<groupId>net.sourceforge.pjl-comp-filter</groupId>
			<artifactId>pjl-comp-filter</artifactId>
			<version>1.7</version>
		</dependency>

		<!-- excel,doc poi操作 -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.12</version>
		</dependency>

<!-- 		<dependency> -->
<!-- 			<groupId>org.quartz-scheduler</groupId> -->
<!-- 			<artifactId>quartz</artifactId> -->
<!-- 			<version>2.2.1</version> -->
<!-- 		</dependency> -->

	</dependencies>
	<build>
		<finalName>mltd-system</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>${jdk.version}</source>
					<target>${jdk.version}</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.mybatis.generator</groupId>
				<artifactId>mybatis-generator-maven-plugin</artifactId>
				<version>1.3.2</version>
				<configuration>
					<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
					<overwrite>true</overwrite>
					<verbose>true</verbose>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>mysql</groupId>
						<artifactId>mysql-connector-java</artifactId>
						<version>${mysql.version}</version>
					</dependency>
					<dependency>
						<groupId>com.github.abel533</groupId>
						<artifactId>mapper</artifactId>
						<version>${mapper.version}</version>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>
</project>


centos下tomcat报错如下
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.22
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Apr 29 2015 11:46:15 UTC
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.22.0
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            2.6.32-504.8.1.el6.x86_64
22-May-2015 11:11:19.375 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
22-May-2015 11:11:19.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /mltd/program/java/jdk1.7.0_75/jre
22-May-2015 11:11:19.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_75-b13
22-May-2015 11:11:19.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
22-May-2015 11:11:19.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /mltd/program/servers/tomcat7070
22-May-2015 11:11:19.377 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /mltd/program/servers/tomcat7070
22-May-2015 11:11:19.377 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/mltd/program/servers/tomcat7070/conf/logging.properties
22-May-2015 11:11:19.377 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
22-May-2015 11:11:19.378 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/mltd/program/servers/tomcat7070/endorsed
22-May-2015 11:11:19.378 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/mltd/program/servers/tomcat7070
22-May-2015 11:11:19.378 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/mltd/program/servers/tomcat7070
22-May-2015 11:11:19.379 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/mltd/program/servers/tomcat7070/temp
22-May-2015 11:11:19.379 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
22-May-2015 11:11:19.574 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-7070"]
22-May-2015 11:11:19.606 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
22-May-2015 11:11:19.622 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-7009"]
22-May-2015 11:11:19.625 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
22-May-2015 11:11:19.633 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 935 ms
22-May-2015 11:11:19.660 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
22-May-2015 11:11:19.660 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.22
22-May-2015 11:11:23.768 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[cmis]2015-05-22 11:11:24,297 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [file:/mltd/deploy2/cmis/WEB-INF/classes/config/applicationContext.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'adminServiceImpl' for bean class [com.bee.cmis.service.impl.AdminServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.bee.service.impl.AdminServiceImpl]
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'adminServiceImpl' for bean class [com.bee.cmis.service.impl.AdminServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.bee.service.impl.AdminServiceImpl]
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:320)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:259)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:87)
	at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:174)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:100)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
	... 22 more
22-May-2015 11:11:24.312 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
22-May-2015 11:11:24.317 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
[cmis]2015-05-22 11:11:24,328 WARN [org.springframework.web.context.support.XmlWebApplicationContext] - Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Fri May 22 11:11:23 CST 2015]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:869)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4776)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5390)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
[cmis]2015-05-22 11:11:24,328 WARN [org.springframework.web.context.support.XmlWebApplicationContext] - Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Fri May 22 11:11:23 CST 2015]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4776)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5390)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
22-May-2015 11:11:24.336 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Thread.sleep(Native Method)
 org.apache.log4j.helpers.FileWatchdog.run(FileWatchdog.java:103)
22-May-2015 11:11:24.343 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /mltd/program/servers/tomcat7070/webapps/docs
22-May-2015 11:11:24.403 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /mltd/program/servers/tomcat7070/webapps/docs has finished in 60 ms
22-May-2015 11:11:24.403 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /mltd/program/servers/tomcat7070/webapps/host-manager
22-May-2015 11:11:24.429 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /mltd/program/servers/tomcat7070/webapps/host-manager has finished in 26 ms
22-May-2015 11:11:24.430 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /mltd/program/servers/tomcat7070/webapps/examples
22-May-2015 11:11:24.765 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /mltd/program/servers/tomcat7070/webapps/examples has finished in 335 ms
22-May-2015 11:11:24.766 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /mltd/program/servers/tomcat7070/webapps/manager
22-May-2015 11:11:24.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /mltd/program/servers/tomcat7070/webapps/manager has finished in 29 ms
22-May-2015 11:11:24.808 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-7070"]
22-May-2015 11:11:24.833 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-7009"]
22-May-2015 11:11:24.852 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 5218 ms







以下是问题补充:

@贺蜜峰:我在windows平台部署没有问题 (2015/05/22 15:07)
@贺蜜峰:五月 22, 2015 3:10:45 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 五月 22, 2015 3:10:45 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/8.0.20 五月 22, 2015 3:10:49 下午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationInitializer types detected on classpath 五月 22, 2015 3:10:49 下午 org.apache.catalina.core.ApplicationContext log 信息: Set web app root system property: 'mltd_sys.root' = [D:\Program\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\mltd-system\] 五月 22, 2015 3:10:49 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing log4j from [D:\Program\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\mltd-system\WEB-INF\classes\config\log4j.properties] 五月 22, 2015 3:10:49 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 五月 22, 2015 3:10:51 下午 org.apache.catalina.core.ApplicationContext log 信息: [CompressingFilter/1.7] CompressingFilter has initialized 五月 22, 2015 3:10:51 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring FrameworkServlet 'SpringMVC' 五月 22, 2015 3:10:53 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-nio-80"] 五月 22, 2015 3:10:53 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-nio-8009"] 五月 22, 2015 3:10:53 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 7747 ms (2015/05/22 15:13)
加载中
0
wad12302
wad12302
 bean class [com.bee.cmis.service.impl.AdminServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.bee.service.impl.AdminServiceImpl]

   如果你没有针对2个service取别名,而是注入的是

@Autowired

adminServiceImpl

无法确定是哪一个

wad12302
wad12302
回复 @贺蜜峰 : 具体的还不清楚,最好先把别名取了再看看
贺蜜峰
贺蜜峰
这个我看一下啊,但我有点疑问的是,我在windows平台能正常运行
0
海亮没有量
海亮没有量
com.bee.service.impl.AdminServiceImpl 还有一个和这个注入时使用的beanID一样。
贺蜜峰
贺蜜峰
这个我看一下啊,但我有点疑问的是,我在windows平台能正常运行 ,而且我的项目只有一个那个service, 只是一个继承了adminServiceImpl
0
贺蜜峰
贺蜜峰
感谢各位回答,没有及时回复各位伙伴,找到错了原因了:是项目构建问题,我用的是maven结构,之前在另外一个包我建立了同样的Service,后期我丢弃了,我maven打包时没有没有clean,原来的maven install的打包文件在,照成了冲突。
返回顶部
顶部