<!-- 解析WebService JAR包 CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.2.4</version>
</dependency>
<!-- 解析WebService JAR包 CXF end-->
<!-- https://mvnrepository.com/artifact/org.jdom/jdom2 -->
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
//命名空间一般为包名的倒序,最后一定要加斜杠
@WebService(targetNamespace = "http://webservice.msunsoft.com/")
public interface PatientService {
//生命对外接口方法和参数
@WebMethod
String sendPatientMsg(@WebParam(name = "name") String name);
}
/**
* webservice接口实现类
* qinfen
命名空间要和接口的命名空间保持一致
endpointInterface指明实现类所实现的接口
*/
@WebService(serviceName = "PatientService",
targetNamespace = "http://webservice.msunsoft.com/",
endpointInterface = "com.msunsoft.webService.PatientService")
@Component
public class PatientServiceImpl implements PatientService {
@Override
public String sendPatientMsg(String name) {
return "hello"+name;
}
}
/**
* cxf配置
* qinfen
*/
@Configuration
public class CxfConfig {
/**
* 注入servlet bean name不能dispatcherServlet 否则会覆盖dispatcherServlet
* @return
*/
@Bean(name = "cxfServlet")
public ServletRegistrationBean cxfServlet() {
return new ServletRegistrationBean(new CXFServlet(),"/services/*");
}
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
//注入对外开放接口
@Bean
public PatientService patientService() {
return new PatientServiceImpl();
}
@Bean(name = "WebServiceDemoEndpoint")
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), patientService());
endpoint.publish("/patient");
return endpoint;
}
}
生成的接口地址为:http://localhost:82/services/patient?wsdl
因为springboot整合了shiro,这个webservice路径没有添加到可以过滤的路径上面去。
filterChainDefinitionMap.put("/services/**", "anon");
“Redis的Key的TTL一到就自动从缓存中剔除” 这个过程是Redis底层自动触发的,而在我们的程序、代码里是完全感知不到的,因为我们得借助某种机制来帮助我们主动地去检测Redis缓存中那些Key已经失效了,而且,我们希望这种检测可以是“近实时”的!
基于Redis的Key失效/存活时间TTL +定时任务调度(用于主动定时的触发,去检测缓存Redis那些失效了的Key,而且希望Cron可以设置得足够合理,实现“近实时”的功效)!
用户提交过来的信息经过处理生成相应的订单号,然后将该订单记录插入数据库、插入缓存Redis,并设置对应的Key的存活时间TTL