Websphere 中的 Spring boot 部署

问题描述 投票:0回答:3

我们正在尝试使用 Spring data Jpa 将 Java 8 Spring boot 应用程序部署到 IBM WebSphere 8.5.5.21 服务器中。该应用程序在本地运行良好,但我们无法使其在 WebSphere 中运行。

这就是我在部署时遇到的错误。

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2/3/23 13:29:39:601 IST] 00000146 SystemOut     O 2023-03-02 13:29:39.600 ERROR 867310 --- [ebContainer : 0] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.NoClassDefFoundError: javax.servlet.http.HttpSessionIdListener
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.24.jar:5.3.24]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175) [spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155) [spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97) [spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174) [spring-web-5.3.24.jar:5.3.24]
        at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:620) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:410) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:171) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1211) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1464) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:642) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:1042) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:795) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1413) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2273) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:436) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:379) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:127) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:654) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5568) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5694) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:668) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:612) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1303) [com.ibm.ws.runtime.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90) ~[na:1.8.0]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.8.0]
        at java.lang.reflect.Method.invoke(Method.java:508) ~[na:1.8.0]
        at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:83) [na:1.8.0]
        at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.8.0]
        at java.lang.reflect.Method.invoke(Method.java:508) ~[na:1.8.0]
        at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:287) [na:1.8.0]
        at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1263) [na:1.8.0]
        at java.security.AccessController.doPrivileged(AccessController.java:708) [na:1.8.0]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [na:1.8.0]
        at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1257) [na:1.8.0]
        at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1096) [na:1.8.0]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:831) [na:1.8.0]
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:813) [na:1.8.0]
        at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1351) [com.ibm.ws.admin.core.jar:na]
        at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) [bootstrap.jar:WAS855.SERV1 [cf212202.02]]
        at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1244) [com.ibm.ws.admin.core.jar:na]
        at com.ibm.ws.management.commands.AdminServiceCommands$InvokeCmd.execute(AdminServiceCommands.java:251) [com.ibm.ws.admin.core.jar:na]
        at com.ibm.ws.console.core.mbean.MBeanHelper.invoke(MBeanHelper.java:246) [wsccore-core_module.jar:na]
        at com.ibm.ws.console.appdeployment.ApplicationDeploymentCollectionAction.execute(ApplicationDeploymentCollectionAction.java:641) [appmanagement-appmanagement_module.jar:na]
        at org.apache.struts.action.RequestProcessor.processActionPerform(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.RequestProcessor.process(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.ActionServlet.process(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.ActionServlet.doPost(Unknown Source) [struts.jar:na]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) [javax.j2ee.servlet.jar:na]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [javax.j2ee.servlet.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1404) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:196) [com.ibm.ws.webcontainer.jar:na]
        at org.apache.struts.action.RequestProcessor.doForward(Unknown Source) [struts.jar:na]
        at org.apache.struts.tiles.TilesRequestProcessor.doForward(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.RequestProcessor.processForwardConfig(Unknown Source) [struts.jar:na]
        at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.RequestProcessor.process(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.ActionServlet.process(Unknown Source) [struts.jar:na]
        at org.apache.struts.action.ActionServlet.doPost(Unknown Source) [struts.jar:na]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) [javax.j2ee.servlet.jar:na]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [javax.j2ee.servlet.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.console.core.servlet.WSCUrlFilter.setUpCommandAssistance(WSCUrlFilter.java:982) [isclite.jar:na]
        at com.ibm.ws.console.core.servlet.WSCUrlFilter.continueStoringTaskState(WSCUrlFilter.java:529) [isclite.jar:na]
        at com.ibm.ws.console.core.servlet.WSCUrlFilter.doFilter(WSCUrlFilter.java:350) [isclite.jar:na]
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:952) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:213) [com.ibm.ws.webcontainer.jar:na]
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1833) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) [com.ibm.ws.runtime.jar:na]
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) [com.ibm.ws.runtime.jar:na]
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892) [com.ibm.ws.runtime.jar:na]
Caused by: java.lang.NoClassDefFoundError: javax.servlet.http.HttpSessionIdListener
        at org.springframework.boot.web.servlet.ServletListenerRegistrationBean.<clinit>(ServletListenerRegistrationBean.java:68) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:156) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:87) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:262) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:236) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext$$Lambda$925/0x00000000fb367d10.onStartup(Unknown Source) ~[na:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:193) ~[spring-boot-2.7.7.jar:2.7.7]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.7.7.jar:2.7.7]
        ... 112 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpSessionIdListener
        at java.net.URLClassLoader.findClass(URLClassLoader.java:610) ~[na:1.8.0]
        at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:254) ~[bootstrap.jar:WAS855.SERV1 [cf212202.02]]
        at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:945) ~[na:2.9 (10-22-2021)]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:890) ~[na:2.9 (10-22-2021)]
        at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:144) ~[bootstrap.jar:WAS855.SERV1 [cf212202.02]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:873) ~[na:2.9 (10-22-2021)]
        at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf212202.02]]
        at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf212202.02]]
        at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:598) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf212202.02]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:873) ~[na:2.9 (10-22-2021)]
        at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:630) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf212202.02]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:873) ~[na:2.9 (10-22-2021)]

我的 pom 文件是这样的。

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.7</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.kgisl.bsibschedulers</groupId>
    <artifactId>BSIB-Schedulers</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>
    <name>bsibschedulers</name>
    <description>BSIB Scheduler services</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-legacy</artifactId>
            <version>1.0.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>Schedulers</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

主课

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class BsibschedulersApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        System.out.println("BsibschedulersApplication Started");
        SpringApplication.run(BsibschedulersApplication.class, args);
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        System.out.println("BsibschedulersApplication Configure");
        return application.sources(BsibschedulersApplication.class);
    }

}

我正在导出为 war 文件。

我做错了什么?

java spring-boot servlets spring-data-jpa websphere
3个回答
1
投票

Spring Boot 2.7.7 依赖于 Java EE 8 技术。 WebSphere Application Server 8.5.5 支持 Java EE 6 技术。版本 9.0.5 支持 Java EE 7 技术。 Open 和 WebSphere Liberty 支持 Java EE 6 Web Profile、7、8 以及 Jakarta 8 和 9。因此 WebSphere Liberty(随 WebSphere Application Server 一起提供)是您应该部署 Spring Boot 2.7.7 应用程序的环境。


0
投票

Spring Boot 2.7.9 或 2.7.7 至少需要 Servlet 5.0 规范和 Java 17。它与支持 Servlet 3.0 和 Java 7/8 的 WebSphere Liberty 8.5.5.21 不兼容。

要在 WebSphere Liberty 8.5.5.21 上部署 Spring Boot 应用程序,您需要使用与 Servlet 3.0 和 Java 7/8 兼容的早期版本的 Spring Boot。例如,您可以使用 Spring Boot 2.3.x 或 2.4.x.

需要注意的是,即使某个版本的 Spring Boot 与特定版本的 WebSphere Liberty 兼容,您的应用程序中使用的其他库或依赖项仍可能存在其他兼容性问题。在将应用程序部署到生产环境之前彻底测试它总是一个好主意。

确保 Javax-servlet-api 依赖看起来像这样

           <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>{Compatible Version}</version>
            </dependency>

这里我没有使用 Scope provided ,因为如果你用“provided” scope 标记它,这意味着它将由服务器提供,而不是在应用程序打包时包含在 WAR 文件中。

您可以从 pom.xml 文件中的 javax.servlet-api 依赖项中删除“提供的”范围。这将确保在应用程序打包并部署到服务器时,依赖项包含在 WAR 文件中。

Spring Boot 2.6.x兼容Java 8,至少需要Servlet 4.0规范,WebSphere Liberty 8.5.5.21支持。

因此,您可以将 Spring Boot 2.6.3 与 Java 8 一起使用,并将您的应用程序部署到 WebSphere Liberty 8.5.5.21。

注意:这适用于 WebSphere Liberty - 8.5.5.21 不适用于 WebSphere 传统版本。

希望这对某些人有帮助。


0
投票
<?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
                        https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <liberty.version>8.5.5.21</liberty.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>

    <repositories>
        <repository>
            <id>oracle-maven-repo</id>
            <url>https://maven.oracle.com</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>1.5.21.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>1.5.21.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>12.2.0.1</version>
            <scope>runtime</scope>
        </dependency>


        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
            <version>1.18.16</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.5.21.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <version>1.5.21.RELEASE</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>Schedulers</finalName>
        <plugins>
            <plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>${liberty.version}</version>
                <configuration>
                    <serverName>defaultServer</serverName>
                    <packageName>${project.groupId}.${project.artifactId}</packageName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

对于WebSphere Liberty 8.5.5.21只支持1.x系列的Spring boot

上面的 pom 工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.