简体   繁体   English

无法在Wildfly 8 AS中部署Spring Boot应用程序

[英]Unable to deploy Spring Boot application in Wildfly 8 AS

I am new to Spring Boot and am facing problem in deploying Spring Boot application to Wildfly 8 server. 我是Spring Boot的新手,在将Spring Boot应用程序部署到Wildfly 8服务器时遇到问题。 I followed some links found in internet to deploy Spring Boot application as war file but did not work. 我跟踪了Internet上的一些链接,以将Spring Boot应用程序部署为war文件,但没有用。

My pom.xml file is as below: 我的pom.xml文件如下:

<?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 http://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>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.13.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

</project>

My starter class is as below: 我的入门班如下:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer  {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DemoApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

I have exposed a Rest method and the Rest Controller looks as below: 我已经公开了Rest方法,Rest Controller如下所示:

package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

    @RestController
    @RequestMapping("/hello")
    public class HelloController {
        @RequestMapping("/sayHello")
        public String sayHello( ) {
            return "hello";
        }
    }

My project runs in embedded tomcat but not in Wildfly server. 我的项目在嵌入式tomcat中运行,但不在Wildfly服务器中运行。 Please help. 请帮忙。

If you are not getting any exception while deploying the application, try to access the application by hitting the following URL and check if it works: 如果在部署应用程序时没有遇到任何异常,请尝试访问以下URL并访问它,以访问该应用程序:
http://<>:<>/ name_of_your_war /hello/sayHello http:// <>:<> / name_of_your_war / hello / sayHello

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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