gpt4 book ai didi

Wicket + Spring Boot + .war文件部署

转载 作者:行者123 更新时间:2023-12-01 14:40:41 25 4
gpt4 key购买 nike

基于此处的示例:https://github.com/Pentadrago/spring-boot-example-wicket
并考虑此处的 jar-to-war 指南:https://spring.io/guides/gs/convert-jar-to-war/
我想将现有的 Wicket + Spring(使用 data-jpa 和安全性)转换为 Spring Boot。让 fat-jar 设置正常工作相当容易,但到目前为止,事实证明我无法将此设置转换为 .war 文件以部署在 Tomcat 中。

问题源于以下指令的冲突:

  • 一方面从非@Configuration类扩展org.springframework.boot.context.web.SpringBootServletInitializer,用于jar-to-war转换指南,
  • 另一方面,为 fat-jar Wicket 示例的 @Configuration 标记类实现 org.springframework.boot.context.embedded.ServletContextInitializer

我一直无法使两者保持一致,以便在使用嵌入式容器进行调试时以及在 Tomcat 中部署为 .war 时都获得一个正常工作的应用程序。

谁能告诉我如何设置一个支持 spring-boot 的 wicket 应用程序,我可以将其部署为 .war 文件?

最佳答案

我所做的并使应用程序运行如下:

我查看了示例项目 https://github.com/Pentadrago/spring-boot-example-wicket你发布的。

然后按照 https://spring.io/guides/gs/convert-jar-to-war/ 上的代码指导我所做的只是进行以下更改:

build.gradle 更改为:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.2.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'

jar {
version = '0.0.1'
}

repositories {
mavenCentral()
}

configurations {
providedRuntime
}

dependencies {
compile(
"org.springframework.boot:spring-boot-starter",
"org.springframework.boot:spring-boot-starter-logging",

"org.springframework:spring-web:4.0.3.RELEASE",
"org.apache.wicket:wicket-spring:6.15.0",
)

testCompile(
"org.springframework.boot:spring-boot-starter-test",
)

providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
}

添加以下类:

HelloWebXml.java

package spring.boot.example.wicket;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class HelloWebXml extends SpringBootServletInitializer {

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

我所做的唯一更改并毫无问题地部署到 Tomcat 7。

这是显示 wicked 开始的日志摘录

2014-08-27 20:57:41.396 INFO 2708 --- [on(3)-127.0.0.1] org.apache.wicket.Application:[wicket-filter] init:Wicket 核心库初始化器

我不确定您混淆的根源是什么,但您必须了解 SpringBootServletInitializerServletContextInitializer 有不同的用途。

关于Wicket + Spring Boot + .war文件部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25532830/

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