gpt4 book ai didi

java.lang.NoClassDefFoundError : com/fasterxml/jackson/core/util/DefaultIndenter

转载 作者:行者123 更新时间:2023-12-02 12:00:45 35 4
gpt4 key购买 nike

我是 Spring 框架的新手。我正在尝试使用Maven。我只想在项目运行时打开索引页但无法做到

错误说java.lang.NoClassDefFoundError:com/fasterxml/jackson/core/util/DefaultIndenter Error here

父级的pom.xml

<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.2</version>
</dependency>

<dependency>
<groupId>com.nishan</groupId>
<artifactId>LifeStyle</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
WebModule的

web.xml

    <?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

dispatcher-servlet.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
">

<context:component-scan base-package="com.nishan.webmodule"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/static/**" location="/WEB-INF/assets"/>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/views/" p:suffix=".jsp"/>

</beans>

导航到索引页面的 servlet 页面

   @Controller
@RequestMapping(value="/")
public class DefaultServlet {

@RequestMapping(method=RequestMethod.GET)
public String index() {
return "index";
}
}

最佳答案

根据 <dependencyManagement> 的文档元素(强调我的):

“从该项目继承的项目的默认依赖关系信息。本节中的依赖关系不会立即解析。相反,当从该项目派生的 POM 声明由匹配的 groupId 和artifactId 描述的依赖关系时,如果尚未指定,则本节中的版本和其他值将用于该依赖项。”

换句话说,您可能缺少正确的<dependency>模块 POM 中的定义。

关于java.lang.NoClassDefFoundError : com/fasterxml/jackson/core/util/DefaultIndenter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47267761/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com