maven整合ssh3启动出现LogManager NoClassDefFoundError错误
maven整合ssh3启动出现错误java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
上网搜了一下,都说没加入log4j的包,但我明明加入进去了啊
slf4j-api, slf4j-log4j12, commons-logging, log4j 都加了,还是报错
下面是我的错误信息和pom.xml
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:813) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:549) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 52 more
<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.cms</groupId> <artifactId>cms</artifactId> <packaging>war</packaging> <version>1.0</version> <name>gdcms Maven Webapp</name><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><spring.version>3.0.2.RELEASE</spring.version><slf4j.version>1.5.6</slf4j.version><aspectj.version>1.6.12</aspectj.version><struts2.version>2.3.15.1</struts2.version><hibernate.version>3.3.2.GA</hibernate.version></properties> <dependencies> <dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.26</version></dependency> <dependency><groupId>ojdbc</groupId><artifactId>ojdbc</artifactId><version>14</version></dependency> <!-- struts2的核心包,其依赖包会自动下载 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>${struts2.version}</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>${struts2.version}</version> </dependency> <!-- struts2与spring的整合插件 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>${struts2.version}</version> </dependency> <dependency><groupId>org.apache.struts</groupId><artifactId>struts2-convention-plugin</artifactId><version>${struts2.version}</version></dependency> <!-- spring的核心包,其他依赖包会自动下载 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>${spring.version}</version></dependency> <!-- 使用spring的aop,aop要依赖aspectjweaver --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version></dependency><dependency><groupId>commons-dbcp</groupId><artifactId>commons-dbcp</artifactId><version>1.3</version></dependency> <!-- 使用这里的工具类对字符串进行MD5加密 --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.7</version> </dependency> <!-- j2ee web spec --><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.1</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency> <!-- hibernate的核心包,使用hibernate4时报错就改用了hibernate3 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency><groupId>org.hibernate</groupId><artifactId>hibernate-annotations</artifactId><version>3.4.0.GA</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-ehcache</artifactId><version>${hibernate.version}</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-jmx</artifactId><version>${hibernate.version}</version></dependency> <!-- spring整合hibernate需要添加上spring的orm的jar包, 由于spring-orm是 依赖于spring-jdbc的, 所以这里即使不配spring-jdbc,maven也会帮我们 下载下来这些依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency><groupId>commons-dbcp</groupId><artifactId>commons-dbcp</artifactId><version>1.3</version></dependency> <dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>${slf4j.version}</version><scope>compile</scope></dependency> <!-- hibernate-core依赖于slf4j-api,而slf4j-api需要一个实现类,这个 实现类jar可以是slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar ,logback-classic.jar其中之一 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.1.1</version></dependency> <!-- log4j日志记录 --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>compile</scope> </dependency> <!-- json --> <dependency><groupId>net.sf.json-lib</groupId><artifactId>json-lib</artifactId><version>2.4</version><classifier>jdk15</classifier></dependency> <!-- junit4用来进行单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.2</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>gdcms</finalName> <plugins><plugin><groupId>org.mortbay.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>7.1.2.v20100523</version><configuration><webAppConfig><contextPath>/cms</contextPath></webAppConfig><connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>8088</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors><!--scanIntervalSeconds>1</scanIntervalSeconds --></configuration></plugin><plugin><!-- Must use java 1.5 or higher for annotations --><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.1</version><configuration><source>1.6</source><target>1.6</target></configuration></plugin></plugins> </build></project>