使用ibmwebsphereapplicationserver进行Spring引导

使用ibmwebsphereapplicationserver进行Spring引导,spring,spring-boot,websphere,Spring,Spring Boot,Websphere,我在尝试将spring引导与WAS(Websphere)服务器一起使用时遇到问题。 我有一个网页,它接受输入,然后执行@controller类 任何帮助都将不胜感激。这就是我们在POM.xml for IBM websphere中需要做的任何特殊事情 下面是我的应用课程内容 @Configuration @ComponentScan @EnableAutoConfiguration public class Application extends SpringB

我在尝试将spring引导与WAS(Websphere)服务器一起使用时遇到问题。 我有一个网页,它接受输入,然后执行@controller类

任何帮助都将不胜感激。这就是我们在POM.xml for IBM websphere中需要做的任何特殊事情

下面是我的应用课程内容

    @Configuration
    @ComponentScan
    @EnableAutoConfiguration
    public class Application  extends SpringBootServletInitializer{
    @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}
public static void main(String[] args) {
    SpringApplication.run(Application.class, args); 
} }
我在pom.xml中添加了>打包>战争

    Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 14 more
Spring boot:run提供了以下错误跟踪

    2016-01-13 16:03:05.331 ERROR 8004 --- [           main] o.s.boot.SpringApplication               : Application startup failed
    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at hello.Application.main(Application.java:23) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95) ~[na:1.7.0]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) ~[na:1.7.0]
at java.lang.reflect.Method.invoke(Method.java:620) ~[na:2.6 (11-14-2014)]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:467) [spring-boot-maven-plugin-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at java.lang.Thread.run(Thread.java:795) [na:1.7.0]
    Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
... 14 common frames omitted
    [WARNING] 
    java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:467)
at java.lang.Thread.run(Thread.java:795)
    Caused by: org.springframework.context.ApplicationContextException:         Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
at hello.Application.main(Application.java:23)
... 6 more
    Caused by: org.springframework.context.ApplicationContextException: 
    Unable to start EmbeddedWebApplicationContext due to missing   EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 14 more
    [INFO] ----------------------------------------------------------------
    [INFO] BUILD FAILURE
     [INFO] ----------------------------------------------------------------

您可以使用WebSphere Liberty Starter应用程序创建将在WebSphere Liberty上运行的Spring引导应用程序:

只需检查“SpringBootWithSpringMVC”,然后单击下载项目。generate项目将包含在WebSphere Liberty上运行简单Spring引导项目所需的所有内容:

  • 应用程序类(上面发布的应用程序类看起来已经正确了)
  • pom.xml文件包含所有必要的SpringBoot依赖项(我怀疑您这里缺少了一些东西)。它还将包含创建WAR文件并将其部署到WebSphereLiberty所需的位,以便您可以看到它立即运行
  • 还有一个生成SpringMVC端点和测试类的示例,以便您可以看到正在运行的示例

为什么这与web sphere有关?您正试图从命令行运行应用程序,因为它需要一个嵌入式容器。您需要添加tomcat(或jetty或…)作为提供的依赖项,以便它仍然可以运行embedded,但在部署到WebSphere时不使用。这一点在我试图将其部署到WebSphere并查看其运行情况的文章中也有解释。如果打开WAS的运行管理控制台并添加生成的WAR(从spring boot:run生成),服务器启动日志将显示我的应用程序已开始运行。这是从spring boot向WAS添加war文件的正确方法吗?
spring boot:run
确实创建了一个包,但也尝试运行它。只需执行
mvn clean package
install
即可创建重新打包的war。然后将其部署到WebSphere。