ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

在JBOSS EAP 6.2.4上部署Spring Boot REST API

2019-11-18 15:19:18  阅读:217  来源: 互联网

标签:spring-boot jboss spring


我正在创建一个新的角度UI和几个将从角度UI调用的Web服务.我使用Spring Boot和Spring工具套件创建了所有Web服务.我对方括号上的角度进行了编码.一切都很好.

现在该将代码移至生产了.我们的生产环境是Jboss EAP 6.4.我使用了角度代码,并成功地使其能够在Jboss服务器上运行.但是我在RESTful Web服务方面遇到问题.我按照-http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging中的说明将服务转换为创建WAR文件

@RestController
@RequestMapping("/fusiontables/")
public class HeatMapUploadController {

    @Autowired
    private HeatMapService mapQueryJsonService;

    @RequestMapping(value="/upload", method=RequestMethod.POST)
    @ResponseBody
    public String getBoundaries(HeatMapUploadCommand uploadCommand) {
        System.out.println("Data is " + uploadCommand);
        return mapQueryJsonService.getMapQueryJson(uploadCommand);
    }
}

在application.properties中,我添加了以下内容
server.servlet-path = / *

这些是我的行家依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.13</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

但是,当我调用Web服务时,我得到了404.当我执行maven程序包时,我没有收到任何错误;如果我说要在Server上运行并选择Jboss EAP 6.2.4,则不会从STS获得任何错误.我看到很多其他人也问过同样的问题.

这些是我得到的唯一警告

19:56:47,462 WARN  [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
19:56:47,463 WARN  [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
19:56:47,889 WARN  [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
19:56:47,889 WARN  [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)



19:56:52,391 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/chartis-services]] (ServerService Thread Pool -- 53) Initializing Spring embedded WebApplicationContext
19:56:52,392 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 53) Root WebApplicationContext: initialization completed in 2652 ms
19:56:53,003 INFO  [org.springframework.boot.context.embedded.ServletRegistrationBean] (ServerService Thread Pool -- 53) Mapping servlet: 'dispatcherServlet' to [/]
19:56:53,004 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'errorPageFilter' to: [/*]
19:56:53,005 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'metricFilter' to: [/*]
19:56:53,005 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'characterEncodingFilter' to: [/*]
19:56:53,006 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
19:56:53,006 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'httpPutFormContentFilter' to: [/*]
19:56:53,006 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'requestContextFilter' to: [/*]
19:56:53,006 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'webRequestLoggingFilter' to: [/*]
19:56:53,006 INFO  [org.springframework.boot.context.embedded.FilterRegistrationBean] (ServerService Thread Pool -- 53) Mapping filter: 'applicationContextIdFilter' to: [/*]
19:56:53,210 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (ServerService Thread Pool -- 53) Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@790420d7: startup date [Tue May 31 19:56:49 MST 2016]; root of context hierarchy
19:56:53,286 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/fusiontables/upload],methods=[POST]}" onto public java.lang.String com.amex.chartis.services.controller.HeatMapUploadController.getBoundaries(com.amex.chartis.services.command.HeatMapUploadCommand)
19:56:53,288 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/fusiontables/legend],methods=[POST]}" onto public java.lang.String com.amex.chartis.services.controller.HeatMapUploadController.getLegend(com.amex.chartis.services.command.HeatMapUploadCommand)
19:56:53,288 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/fusiontables/allzips],methods=[POST]}" onto public java.lang.String com.amex.chartis.services.controller.HeatMapUploadController.getAllZips(com.amex.chartis.services.command.HeatMapUploadCommand)
19:56:53,289 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/zip/byradius],methods=[POST]}" onto public java.lang.String com.amex.chartis.services.controller.ZipUploadController.getRadialDistance(com.amex.chartis.services.command.ZipUploadCommand)
19:56:53,295 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
19:56:53,296 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 53) Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

解决方法:

我添加了以下onStartup并解决了该问题

@Override
public void onStartup(ServletContext container) throws ServletException {
    WebApplicationContext context = getContext();
    ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet(context));
    registration.setLoadOnStartup(1);
    registration.addMapping("/*");
    super.onStartup(container);
}

private WebApplicationContext getContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation(Application.class.getName());
    return context;
}

标签:spring-boot,jboss,spring
来源: https://codeday.me/bug/20191118/2029297.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有