Spring boot项目引入jar包时启动报错:java.lang.StackOverflowError

原创 2018-10-19 17:52 阅读(1759)次

我在学习spring cloud zipkin时,引入如下jar后,

	<!-- 引入zipkin-server -->
	<dependency>
		<groupId>io.zipkin.java</groupId>
		<artifactId>zipkin-server</artifactId>
		<version>2.11.7</version>
	</dependency>
	<!-- 引入zipkin-server 图形化界面 -->
	<dependency>
		<groupId>io.zipkin.java</groupId>
		<artifactId>zipkin-autoconfigure-ui</artifactId>
		<version>2.11.7</version>
	</dependency> 

项目一直起不来,一直报如下错误:

SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:112)
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:125)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)

栈内存溢出。。

修改启动的内存参数也无效,后来百度了下得到点启示,应该是加入的jar中有log4j的依赖与spring boot自带的冲突,造成类加载有问题,有可能是死循环造成内存不足,解决办法就是排除掉新加入的jar包中log4j的依赖删除了。这样就OK了。

	<!-- 引入zipkin-server -->
	<dependency>
		<groupId>io.zipkin.java</groupId>
		<artifactId>zipkin-server</artifactId>
		<version>2.11.7</version>
		<exclusions>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-log4j2</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<!-- 引入zipkin-server 图形化界面 -->
	<dependency>
		<groupId>io.zipkin.java</groupId>
		<artifactId>zipkin-autoconfigure-ui</artifactId>
		<version>2.11.7</version>
	</dependency>