=================================================================================
org.apache.cxf
cxf-rt-frontend-jaxws
3.1.6
org.apache.cxf
cxf-rt-transports-http
3.1.6
加上这两个jar包。
====================================================================================
=============================================================================
设置一个登陆接口类
package com.webservice.demo.services;
import javax.jws.WebService;
import java.util.Map;
@WebService(name = “LoginService”, // 暴露服务名称
targetNamespace = “http://java18.cn” // 命名空间
)
public interface LoginService {
Map<String,Object> userLogin();
}
===============================================================================
package com.webservice.demo.services.impl;
import com.webservice.demo.services.LoginService;
import javax.jws.WebService;
import java.util.HashMap;
import java.util.Map;
@WebService(serviceName = “LoginService”, // 与接口中指定的name一致
targetNamespace = “http://java18.cn”, // 与接口中的命名空间一致
endpointInterface = “com.webservice.demo.services.LoginService”// 接口地址
)
public class LoginServiceImpl implements LoginService {
@Override
public Map<String, Object> userLogin() {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(“errCode”,00000);
resultMap.put(“errMsg”,null);
return resultMap;
}
}
================================================================================
package com.webservice.demo.config;
import com.webservice.demo.services.LoginService;
import com.webservice.demo.services.impl.LoginServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
@Configuration
public class CxfConfig {
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(),“/webservice/*”);
}
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
@Bean
public LoginService loginService() {
return new LoginServiceImpl();
}
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), loginService());
endpoint.publish(“/api”);
return endpoint;
}
}
步骤 7 Parameter 0 of method errorPageCustomizer in ErrorMvcAutoConfiguration 异常解决
===================================================================================================================================================
现在直接启动会报错的。
解决方法如下
最后
针对最近很多人都在面试,我这边也整理了相当多的面试专题资料,也有其他大厂的面经。希望可以帮助到大家。
上述的面试题答案都整理成文档笔记。 也还整理了一些面试资料&最新2021收集的一些大厂的面试真题(都整理成文档,小部分截图)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
f0b86edfb52b4c297.png)
最后
针对最近很多人都在面试,我这边也整理了相当多的面试专题资料,也有其他大厂的面经。希望可以帮助到大家。
[外链图片转存中…(img-5Bnz8qua-1714361093899)]
上述的面试题答案都整理成文档笔记。 也还整理了一些面试资料&最新2021收集的一些大厂的面试真题(都整理成文档,小部分截图)
[外链图片转存中…(img-LO7OuOVM-1714361093900)]
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。