我已经用Google搜索了这个问题,但我找不到任何针对此案例的内容 . 我发现了很多“如何将Spring Boot WAR部署到Tomcat”,但没有提到使用Spring Boot包装现有的Tomcat WAR .
我需要重新配置.1407756_t . This solution不起作用,因为它取决于绝对位置可用的WAR,而我们正试图在Spring Boot WAR中打包"application" WAR . 然后我们可以像这样添加WAR的上下文:
Context context = tomcat.addWebapp("myapp", Thread.currentThread().getContextClassLoader().getResource("myapp.war").getPath());
这几乎正常 . 我遇到一个特定问题的问题 . 当现有WAR文件被放入Spring Boot项目时,它将被放入 /WEB-INF/lib-provided
而不是 /WEB-INF/classes
. 我可以't find a way to get the embedded Tomcat to add a WAR file from this location. The ClassLoader won' t加载它因为它不在 WEB-INF/classes
之下 .
从 /WEB-INF/lib-provided
获取此WAR是否有一种灵巧的方式(或任何方式)?
1 回答
对于其他需要执行此操作的人,答案是使用
maven-dependency-plugin
并将spring-boot-maven-plugin
设置为从资源中排除WAR文件(否则您将获得Spring Boot WAR中包含的两个WAR副本):