Digest:今天Spring Boot 应用启动成功,访问接口出现如下错误,不知到导致问题关键所在,记录一下这个问题。

浏览器报500错误

项目代码如下

Controller.java

package com.lints.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; /**
* @Author Lints
* @Date 2019/10/31 9:06
* @Description This is description of class
* @Since version-1.0
*/
@RestController
public class HelloController {
/**
* @Author Lints
* @Date 2019/10/31 9:06
* @Description 这用于处理浏览器hello请求
* @Param null
* @Return java.lang.String
* @Since version-1.0
*/
@ResponseBody
@RequestMapping("/hello")
public String helloWorld(){
return "Hello World!";
}
}

HelloWorldApp.java

package com.lints;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; /**
* @Author Lints
* @Date 20:47
* @Description This is a Spring Boot application
* @Since version-1.0
*/ @SpringBootApplication
public class HelloWorldApp {
/**
* @Author Lints
* @Date 2019/10/30 21:25
* @Description This is description of method
* @Param [args]
* @Return void
* @Since version-1.0
*/
public static void main(String[] args) {
//启动Spring应用
SpringApplication.run(HelloWorldApp.class,args);
}
}

pom.xml

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

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/>
</parent> <groupId>com.lints</groupId>
<artifactId>spring-boot-helloworld</artifactId>
<version>1.0-SNAPSHOT</version> <name>spring-boot-helloworld</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.8.RELEASE</version>
</dependency>
</dependencies> <build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

解决办法

将pom.xml中 Spring版本换成 2.1.6 问题解决

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

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <!--- 把Spring版本换成 2.1.6 问题解决 <version>2.2.0.RELEASE</version> ---> <version>2.1.6.RELEASE</version>
<relativePath/>
</parent>

【Spring Boot】java.lang.NoSuchMethodError: org.springframework.web.util.UrlPathHelper.getLookupPathForRequest(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;)Ljava/lang/String;的更多相关文章

  1. 【Spring Boot】定时任务

    [Spring Boot]定时任务 测试用业务Service package com.example.schedule.service; import org.springframework.ster ...

  2. 【spring boot】配置信息

    ======================================================================== 1.feign 超时配置 2.上传文件大小控制 3.J ...

  3. java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;问题

    在springsecurity学习中,在加入spring有关的jar包后,出现java.lang.NoSuchMethodError: org.springframework.web.context. ...

  4. java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnv

    转自:https://blog.csdn.net/u012941811/article/details/16960493 ava.lang.NoSuchMethodError: org.springf ...

  5. maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    环境:Groovy/Grails Tool Suite 3.1.0.RELEASE(BASED ON ECLIPSE JUNO 3.8.1).JDK1.6.Maven3.05.Tomcat6 错误描述 ...

  6. maven web启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    问题描述 SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfi ...

  7. 解决java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

    启动eclipse 发现如下错误 Error configuring application listener of class org.springframework.web.util.Log4jC ...

  8. java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

    一:如果出现下面的错误信息,如果你的项目是Maven结构的,那么一般都是你的项目的Maven Dependencies没有添加到项目的编译路径下: 信息: The APR based Apache T ...

  9. Maven项目Eclipse启动时报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

    Eclipse中启动Maven项目时报如下错误: 严重: Error configuring application listener of class org.springframework.web ...

随机推荐

  1. 阿里云安装RocketMQ

    说明: 我的阿里云是centos 6.9 jdk 1.8.0_192-b12(安装教程参照:https://www.cnblogs.com/kingsonfu/p/9801556.html) mave ...

  2. 阿里云服务器ecs配置之安装nginx

    一.简介 Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttpd具有占有内存少,稳定性高等优势.它最常的用途是提供反向代理服务. 二 .安装 1.准备工作 Nginx ...

  3. java字符串,数组,集合框架重点

    1.字符串的字面量是否自动生成一个字符串的变量? String  str1  =  “abc”; Sring  str2  =   new String (“abc”); 对于str1:Jvm在遇到双 ...

  4. LAMP模拟搭建wordpress,phpmyadmin环境

    1.安装需要的环境,centos7的mysql叫mariadb,所有的配置文件默认就可以 [root@test ~]# yum install httpd php mariadb mariadb-se ...

  5. 面试官:你有m个鸡蛋,如何用最少的次数测出鸡蛋会在哪一层碎?

    假设你面前有一栋n层的大楼和m个鸡蛋,假设将鸡蛋从f层或更高的地方放扔下去,鸡蛋才会碎,否则就不会.你需要设计一种策略来确定f的值,求最坏情况下扔鸡蛋次数的最小值. leetcode原题链接 乍一看这 ...

  6. [scrapy-redis] 将scrapy爬虫改造成分布式爬虫 (2)

    1. 修改redis设置 redis默认处在protection mode, 修改/etc/redis.conf, protected-mode no, 或者给redis设置密码, 将bind 127 ...

  7. 基于微信小程序云开发实现的婚礼邀请函模板,可自行定制开发

    这个婚礼邀请函是之前帮别人做的,现在人家婚礼举办过了也没啥关系了,想着就修改成通用模板进行开源,方便大家尤其是小白们克隆项目之后稍微修改就能够直接使用. 当时自己开始这个项目时候也是查阅了很多教程文章 ...

  8. 11g bug event 'cursor: mutex S'-引发的CPU冲高问题

    问题背景:客户反应数据库服务器CPU占用过高 1> 确认问题根源登录客户DB服务器: top 查看当前负载 (几乎100%)top - 10:47:55 up 29 days, 21:51, 3 ...

  9. 并发新构件之CyclicBarrier

    CyclicBarrier:叫做循环栅栏,名字挺好听的.JDK描述:允许一组线程全部等待彼此达到共同屏障点的同步辅助. 循环阻塞在涉及固定大小的线程方的程序中很有用,这些线程必须偶尔等待彼此. 屏障被 ...

  10. springboot依赖的一些配置:spring-boot-dependencies、spring-boot-starter-parent、io.spring.platform

    springboot里会引入很多springboot starter依赖,这些依赖的版本号统一管理,springboot有几种方案可以选择. 一.spring-boot-dependencies 有两 ...