【问题标题】:spring tool suite can not deploy example webservice on tomcatspring 工具套件无法在 tomcat 上部署示例 web 服务
【发布时间】:2015-10-08 22:25:00
【问题描述】:

我在 EJB 和 JBoss 方面有一些经验,并且了解 Web 服务的基础知识,但我是 Spring 新手。

所以我尝试部署示例 Spring WS 项目 gs-rest-service-complete 而不做任何更改。它在 Spring Boot 上运行,但我无法在外部 Tomcat 服务器上部署和访问它。

这就是我所做的:我安装了 Spring Tool Suite Version: 3.6.4.RELEASE 和 Apache Tomcat 8.0.24 并将 Tomcat 定义为 Spring Tool Suite 中的新服务器。 它似乎有效,因为我可以部署(和访问)示例 Spring MVC 项目,并且可以在 Tomcat 上部署另一个(不是 Spring 示例)Web 服务。

但是我无法部署 gs-rest-service-complete 项目。我将 pom.xml 中的包装更改为“war”,但没有帮助。任何提示我可以做什么?

谢谢你,卡杜塔

【问题讨论】:

    标签: spring tomcat deployment suite


    【解决方案1】:

    最后我在这个网站的底部找到了答案: https://spring.io/blog/2014/03/07/deploying-spring-boot-applications

    我必须执行三个步骤才能使其运行:

    • 在 pom.xml 中将打包更改为 war。
    • 注释掉 pom.xml 中 spring-boot-maven-plugin 的声明。
    • 改变Application类继承自SpringBootServletInitializer并覆盖方法configure。这是在 tomcat 中注册应用程序所必需的。

    现在 Application 类看起来像这样:

        package hello;
    
        import org.springframework.boot.SpringApplication;
        import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 
        import org.springframework.boot.builder.SpringApplicationBuilder; 
        import org.springframework.boot.context.web.SpringBootServletInitializer;
        import org.springframework.context.annotation.ComponentScan;
        import org.springframework.context.annotation.Configuration;
    
        @Configuration
        @ComponentScan
        @EnableAutoConfiguration
        public class Application extends SpringBootServletInitializer {
    
    
        private static Class<Application> applicationClass = Application.class;
    
        public static void main(String[] args) {
            SpringApplication.run(applicationClass, args);
        }
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(applicationClass);
        }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 2014-12-24
      • 2016-04-03
      • 2018-06-07
      相关资源
      最近更新 更多