【问题标题】:Application error when creating simple web service using Spring Boot使用 Spring Boot 创建简单 Web 服务时出现应用程序错误
【发布时间】:2018-12-14 10:06:46
【问题描述】:

创建返回“hello”字符串的简单 Web 服务时出现以下错误

Whitelabel 错误页面 此应用程序没有明确的映射 /error,因此您将其视为后备。

我的网络服务端点:

@WebService
        public class HelloWs {
            @WebMethod
            public String hello() {
                return "hello";
            }
      }

我的配置类:

@Configuration
public class WebServiceConfig {
    @Autowired
    private Bus bus;
    @Bean
    public Endpoint endpoint() {
        Endpoint endpoint = new EndpointImpl(bus, new HelloWs());
        endpoint.publish("/hello");
        return endpoint;
    }
}

我的pom.xml 依赖项:

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

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

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
            <version>3.2.7</version>
        </dependency>

    </dependencies>

我的项目结构:

【问题讨论】:

    标签: web-services spring-boot cxf spring-boot-maven-plugin


    【解决方案1】:

    如果您使用mvn spring-boot:run,则 cxf Web 服务托管在 /services/*,因此在 url http://localhost:8080/services 您将找到 cxf 端点列表,在您的情况下,它只有一个。你会在http://localhost:8080/services/hello?wsdl位置获得wsdl

    如果您要部署到任何应用服务器,请在服务之前添加上下文路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      • 2021-03-18
      • 2020-08-16
      • 1970-01-01
      相关资源
      最近更新 更多