带有Jboss eap 6.4的Spring boot 2.0.1

时间:2018-04-24 13:21:12

标签: spring spring-boot jboss

是否有人将Spring boot 2.0.1(带入门版)生成的战争部署到Jboss EAP 6.4?

我试着做一些调整,但没有成功。

这里有什么亮点吗?

谢谢!

2 个答案:

答案 0 :(得分:8)

您只能将Spring Boot 2.x应用程序部署到任何 Servlet 3.1 + 兼容容器,而JBOSS EAP 6.x仅支持 Servlet 3.0

您必须将spring boot降级到1.5.x或将JBOSS升级到7 +

以下是对文档的引用

https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#getting-started-system-requirements-servlet-containers

https://access.redhat.com/articles/113373

答案 1 :(得分:0)

我通过遵循advice获得成功,请参见示例:

    package com.me.app.deployment.webapp;

import com.me.app.AppSpringConfiguration;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletRegistrationBean;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import static java.util.Collections.emptySet;

@SpringBootApplication(exclude = {
        SecurityAutoConfiguration.class
})
@PropertySource(value = "file:/some/path/some.properties", ignoreResourceNotFound = true)
@Import({AppSpringConfiguration.class})
public class WebAppRunner extends SpringBootServletInitializer {

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

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        servletContext.setSessionTrackingModes(emptySet());
        super.onStartup(servletContext);
    }

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

    @Bean
    public DispatcherServletRegistrationBean dispatcherServletRegistration(
            DispatcherServlet dispatcherServlet,
            ObjectProvider<MultipartConfigElement> multipartConfig) {
        DispatcherServletRegistrationBean registration = new DispatcherServletRegistrationBean(
                dispatcherServlet, "/*");
        registration.setName("dispatcherServlet");
        registration.setLoadOnStartup(-1);
        multipartConfig.ifAvailable(registration::setMultipartConfig);
        return registration;
    }

}

然后在/webapp/WEB-INF/jboss-deployment-structure.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclusions>
            <module name="org.apache.log4j"/>
            <module name="org.apache.commons.logging"/>
            <module name="org.slf4j"/>
            <module name="org.slf4j.impl"/>
            <module name="javax.validation"/>
            <module name="javax.validation.api"/>
            <module name="org.hibernate"/>
            <module name="org.hibernate.validator"/>
            <module name="javaee.api"/>
            <module name="javax.faces.api"/>
            <module name="org.jboss.as.connector"/>
            <module name="org.jboss.as.ee"/>
            <module name="org.jboss.ironjacamar.impl"/>
            <module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>
            <module name="org.jboss.weld.core"/>
            <module name="org.jboss.weld.spi"/>
        </exclusions>
        <dependencies>
            <module name="com.me.deps"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>