简体   繁体   中英

Spring boot 2.0.1 with Jboss eap 6.4

Has anyone make the war generated by Spring boot 2.0.1 (with starter) deployable to Jboss EAP 6.4?

I tried to do some tweaking, but not successful.

Any shed some light here?

Thanks!

You can only deploy Spring Boot 2.x applications to any Servlet 3.1+ compatible container and JBOSS EAP 6.x only supports Servlet 3.0 .

You have to either downgrade spring boot to 1.5.x or upgrade JBOSS to 7+

Below are the references to docs

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

I've had success by following advice , see example:

    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;
    }

}

And then in /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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM