Ced*_*ult 5 maven maven-war-plugin spring-boot
我正在使用Maven多模块与战争取决于另一场战争.
Spring Boot webapp依赖于仅提供html文件的基本webapp.
当我运行Spring Boot应用程序时,我能够从主webapp(Spring Boot)访问服务和html,但我无法从依赖战争中访问html文件(404).但是这些html文件很好地打包在Spring Boot webapp war中......
这是一个显示问题的项目:https:
//github.com/cthiebault/spring-boot-war-overlays
这个项目有2个战争模块:
这是main-webapp 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>spring-boot-overlays</groupId>
<artifactId>parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>main-webapp</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>spring-boot-overlays</groupId>
<artifactId>dependency-webapp</artifactId>
<version>0.1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>spring-boot-overlays</groupId>
<artifactId>dependency-webapp</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<start-class>hello.Application</start-class>
</properties>
</project>
Run Code Online (Sandbox Code Playgroud)
运行webapp:
mvn install
cd main-webapp
mvn spring-boot:run
Run Code Online (Sandbox Code Playgroud)
http://localhost:8080/index.html - >好的
o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/index.html]
s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /index.html
s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/index.html]
o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/index.html] are [/**]
o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/index.html] are {}
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/index.html] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler@25595861] and 1 interceptor
o.s.web.servlet.DispatcherServlet : Last-Modified value for [/index.html] is: -1
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [index.html] against base location: ServletContext resource [/]
o.s.w.s.r.ResourceHttpRequestHandler : Found matching resource: ServletContext resource [/index.html]
o.s.w.s.r.ResourceHttpRequestHandler : Determined media type 'text/html' for ServletContext resource [/index.html]
o.s.w.s.r.ResourceHttpRequestHandler : Resource not modified - returning 304
o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
o.s.web.servlet.DispatcherServlet : Successfully completed request
Run Code Online (Sandbox Code Playgroud)
http://localhost:8080/dependency/index.html - >错误404
o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/dependency/index.html]
s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /dependency/index.html
s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/dependency/index.html]
o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/dependency/index.html] are [/**]
o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/dependency/index.html] are {}
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/dependency/index.html] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler@25595861] and 1 interceptor
o.s.web.servlet.DispatcherServlet : Last-Modified value for [/dependency/index.html] is: -1
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [dependency/index.html] against base location: ServletContext resource [/]
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [dependency/index.html] against base location: class path resource [META-INF/resources/]
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [dependency/index.html] against base location: class path resource [resources/]
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [dependency/index.html] against base location: class path resource [static/]
o.s.w.s.r.ResourceHttpRequestHandler : Trying relative path [dependency/index.html] against base location: class path resource [public/]
o.s.w.s.r.ResourceHttpRequestHandler : No matching resource found - returning 404
o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
o.s.web.servlet.DispatcherServlet : Successfully completed request
Run Code Online (Sandbox Code Playgroud)
什么是错的?
Spring Boot 插件不知道覆盖层(这是非常基本的),因此如果您愿意,可以在 github 中提出有关该问题的问题。不过,项目中的 WAR 文件可以正常部署并运行(使用 java -jar),因此其他一切都正常。
| 归档时间: |
|
| 查看次数: |
3484 次 |
| 最近记录: |