gpt4 book ai didi

java - Spring 启动执行: org. apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;V

转载 作者:太空宇宙 更新时间:2023-11-04 10:22:47 25 4
gpt4 key购买 nike

我是 Spring Boot 新手,尝试在 Spring Boot 中启动一个简单的项目,但无法将项目作为 Java 应用程序启动,并收到下面提到的错误消息,

Project Structure

SpringBootWebApplication.java

package main.java.com.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class SpringBootWebApplication extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootWebApplication.class);
}

public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootWebApplication.class, args);
}

}

WelcomeController.java

package main.java.com.test;

import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class WelcomeController {

// inject via application.properties
@Value("${welcome.message:test}")
private String message = "Hello World";

@RequestMapping("/")
public String welcome(Map<String, Object> model) {
model.put("message", this.message);
return "welcome";
}

}

欢迎.jsp

<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en">
<head>

<!-- Access the bootstrap Css like this,
Spring boot will handle the resource mapping automcatically -->
<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />

<!--
<spring:url value="/css/main.css" var="springCss" />
<link href="${springCss}" rel="stylesheet" />
-->
<c:url value="/css/main.css" var="jstlCss" />
<link href="${jstlCss}" rel="stylesheet" />

</head>
<body>

<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Spring Boot</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
</div>
</nav>

<div class="container">

<div class="starter-template">
<h1>Spring Boot Web JSP Example</h1>
<h2>Message: ${message}</h2>
</div>

</div>

<script type="text/javascript" src="webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>

</html>

下面是我在/WEB-INF/lib 下添加的 Jar 列表

Jar's Added

作为 java 应用程序运行项目时收到错误消息

  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.2.RELEASE)

Jun 18, 2018 2:52:41 PM main.java.com.mykong.SpringBootWebApplication logStarting
INFO: Starting SpringBootWebApplication on BR-LL58000 with PID 9864 (C:\Users\tpucchin\workspace\SpringHelloWorld\build\classes started by TPUCChin in C:\Users\tpucchin\workspace\SpringHelloWorld)
Jun 18, 2018 2:52:41 PM main.java.com.mykong.SpringBootWebApplication logStartupProfileInfo
INFO: No active profile set, falling back to default profiles: default
Jun 18, 2018 2:52:41 PM org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext prepareRefresh
INFO: Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@81db25: startup date [Mon Jun 18 14:52:41 BST 2018]; root of context hierarchy
Jun 18, 2018 2:52:42 PM org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
Jun 18, 2018 2:52:42 PM org.springframework.boot.SpringApplication reportFailure
SEVERE: Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
at main.java.com.mykong.SpringBootWebApplication.main(SpringBootWebApplication.java:20)
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:107)
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.setPatternToTomcat8SkipFilter(SkipPatternJarScanner.java:62)
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.<init>(SkipPatternJarScanner.java:57)
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.apply(SkipPatternJarScanner.java:88)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:207)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:176)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
... 8 more

我在这里做错了什么以及如何解决这个错误?我已尝试了之前查询中提供的答案,但无法解决此问题。

最佳答案

转到项目属性 -> 项目方面 -> 从运行时取消选中 tomcat。

关于java - Spring 启动执行: org. apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;V,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50911254/

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