无法解析的依赖 org.springframework.core.KotlinDetector.isKotlinReflectPresent()z [英] unresolvable dependency org.springframework.core.KotlinDetector.isKotlinReflectPresent()z

查看:93
本文介绍了无法解析的依赖 org.springframework.core.KotlinDetector.isKotlinReflectPresent()z的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在 tomcat 中部署我的应用程序时遇到以下错误.我在 eclipse 中配置了 tomcat,tomcat 版本为 8.5.3,java 版本为 1.8.

Hi everyone I am getting the following error while deploying my application in tomcat.I have configiured tomcat in eclipse and the version tomcat is 8.5.3 and the version of java is 1.8.

DEBUG   2018-10-10 11:52:09,243 [localhost-startStop-1] org.springframework.web.servlet.DispatcherServlet  - Servlet with name 'spitter' will try to create custom WebApplicationContext context of class 'org.springframework.web.context.support.XmlWebApplicationContext', using parent context [null]
ERROR   2018-10-10 11:52:09,368 [localhost-startStop-1] org.springframework.web.servlet.DispatcherServlet  - Context initialization failed
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.context.support.XmlWebApplicationContext]: Unresolvable class definition; nested exception is java.lang.NoSuchMethodError: org.springframework.core.KotlinDetector.isKotlinReflectPresent()Z
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:132)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:630)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:686)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:554)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4978)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5290)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.springframework.core.KotlinDetector.isKotlinReflectPresent()Z
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:171)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:122)
    ... 22 more

我的 pom.xml 中有以下依赖项

I have the following dependencies in my pom.xml

<properties>
  <spring-version>5.0.9.RELEASE</spring-version>
  <junit-version>4.12</junit-version>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  </properties>



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

    <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.3</version>
</dependency>
 <dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.17</version>
</dependency>  

<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>5.0.8.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>5.0.8.RELEASE</version>
</dependency>


    <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring-version}</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring-version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${spring-version}</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring-version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring-version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>

</dependency>

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>2.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>6.0.13.Final</version>
</dependency>

<!-- Jackson JSON Processor -->
 <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.4</version>
</dependency> 

  <!-- https://mvnrepository.com/artifact/org.hornetq/hornetq-core -->
<dependency>
    <groupId>org.hornetq</groupId>
    <artifactId>hornetq-core</artifactId>
    <version>2.2.18.Final</version>
</dependency>
  </dependencies>

在我的目标 war 的 lib 文件夹中还包含我在 pom 中声明的所有 jar.我尝试清理和清理 tomcat 的工作目录,但仍然遇到相同的错误.

In the lib folder of my target war also contains all the jars that i have declared in the pom.I have tried to clean and clean working directory of tomcat but still getting the same error.

我的web.xml如下

My web.xml is as follows

<servlet>
<servlet-name>spitter</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- if we want to use custom configuration file use init param attribute and set contextConfigLocation parameter to our 
custom file otherwise it will look forservletname-servlet.xml file in WEB-INF location -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spitter</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- <filter>
<filter-name>spingSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter> -->
</web-app>

谁能帮我解决这个问题.提前致谢

can anyone please help me out on this issue.Thanks in advance

推荐答案

对我来说,问题是 spring-core 的旧版本(4.x,其余库在 5.2.8.RELEASE)) 已经悄悄进入,它是通过 spring-retry 依赖来实现的.mvn dependency:tree 帮我解决了这个问题.

For me, the problem was that an older version of spring-core (4.x, where as rest of the libraries were at 5.2.8.RELEASE)) had creeped in and it was coming via spring-retry dependency. mvn dependency:tree helped me figure this out.

排除它就可以了:

<dependency>
  <groupId>org.springframework.retry</groupId>
  <artifactId>spring-retry</artifactId>
  <version>1.3.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </exclusion>
  </exclusions>
</dependency>

这篇关于无法解析的依赖 org.springframework.core.KotlinDetector.isKotlinReflectPresent()z的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆