springboot1.4CXF配置
启动类:
package com.eshore.main;
import org.tor.Connector;
import http11.Http11NioProtocol;
import f.transport.servlet.CXFServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.t.embedded.ConfigurableEmbeddedServletContainer;
import org.t.embedded.EmbeddedServletContainerCustomizer;
import org.t.embedded.ServletRegistrationBean;
import org.at.TomcatConnectorCustomizer;
import org.at.TomcatEmbeddedServletContainerFactory;
import t.annotation.Bean;
import t.annotation.ImportResource;
@ImportResource(value = { "l" })
@SpringBootApplication
public class SpringBootStarter implements EmbeddedServletContainerCustomizer{
private static final Logger logger = Logger(SpringBootStarter.class);
private static final int CXF_PORT = 9090;
public static void main(String[] args) {
SpringApplication.run(SpringBootStarter.class, args);
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
return new ServletRegistrationBean(new CXFServlet(), "/services/*");
}
/*
* 设置启动端⼝号
*/
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(CXF_PORT);
TomcatEmbeddedServletContainerFactory tomcatFactory = (TomcatEmbeddedServletContainerFactory)container;        tomcatFactory.addConnectorCustomizers(new MyTomcatConnectorCustomizer());
}
class MyTomcatConnectorCustomizer implements TomcatConnectorCustomizer
{
public void customize(Connector connector)
{
Http11NioProtocol protocol = (Http11NioProtocol) ProtocolHandler();
//设置最⼤连接数
protocol.setMaxConnections(2800);
//设置最⼤线程数
protocol.setMaxThreads(2800);
protocol.setConnectionTimeout(40000);
}
}
}
接⼝类:
import javax.jws.WebParam;
import javax.jws.WebService;
import com.eshore.db.SendDto;
@WebService
public interface ServerSendSmsService {
@WebMethod
String sendSms(SendDto sms);
@WebMethod
String getState(@WebParam(name = "requestId") String requestId); }
实现类: 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.eshore.db.SendDto;
import com.eshore.db.SmsService;
import ssage.SmsMessage;
import com.eshore.sender.ServiceSender;
import com.eshore.util.MD5Crypter;
@WebService(endpointInterface="com.eshore.db.webservice.ServerSendSmsService",serviceName="ServerSendSmsService") public class ServerSendSmsServiceImpl implements ServerSendSmsService{
private Logger Class());
@Autowired
private ServiceSender sender;
@Autowired
private SmsService smsService;
@Override
public String sendSms(SendDto dto) {
log.info("receive message :{}",String());
String requestId="";
SmsMessage msg=new SmsMessage();
msg.Content());
msg.Receivers());
msg.Sender());
msg.Content());
String originalString=String.valueOf(System.currentTimeMillis())+Content();
requestId=MD5Crypter.MD5Encode(originalString);
msg.setMessageId(requestId);
//sender.send(msg);
log.info("requestId:{}",requestId);
log.info("controller ");
requestId="it's a test";
return requestId;
}
@Override
public String getState(String requestId) {
return "getstateTest";
//return smsService.queryByRequestId(requestId);
}
}
配置⽂件:
<beans xmlns="/schema/beans"
xmlns:xsi="/2001/XMLSchema-instance"
xmlns:jaxws="/jaxws"
xsi:schemaLocation="/jaxws /schemas/jaxws.xsd
/schema/beans  /schema/beans/spring-beans.xsd"
default-autowire="byName" default-lazy-init="true">
<description>基于Apache CXF的Web Service配置⽂件</description>
<import resource="classpath:META-INF/l"/>
<import resource="classpath:META-INF/l"/>
<import resource="classpath:META-INF/l"/>
<!-- -->
<jaxws:endpoint id="ServerSendSmsService" address="/ServerSendSmsService">
<jaxws:implementor>
<ref bean="serverSendSmsServiceImpl" />
</jaxws:implementor>
</jaxws:endpoint>
<bean id="serverSendSmsServiceImpl"
class="com.eshore.db.webservice.ServerSendSmsServiceImpl" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/schema/beans" xmlns:xsi="/2001/
XMLSchema-instance" xmlns:tx="www.springframework  xmlns:aop="/schema/aop" xmlns:context="/schema/context"
xmlns:task="/schema/task"
xsi:schemaLocation="/schema/beans
/schema/beans/spring-beans-3.0.xsd
/schema/tx
/schema/tx/spring-tx-3.0.xsd
/schema/aop
/schema/aop/spring-aop-3.0.xsd
/schema/task
/schema/task/spring-task-3.0.xsd
/schema/context
/schema/context/spring-context-3.0.xsd">
<import resource="classpath*:l"/>
<context:component-scan base-package="com.eshore.*" />
springboot aop
<task:annotation-driven />
<bean
class="org.springframework.fig.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
<!-- 配置数据源 -->
<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="url" value="${jdbc_url}" />
<property name="username" value="${jdbc_username}" />
<property name="password" value="${jdbc_password}" />
<property name="initialSize" value="10" />
<property name="maxActive" value="60" />
<property name="minIdle" value="20" />
<property name="maxWait" value="60000" />
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="33" />
<property name="validationQuery" value="${validationQuery}" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="testOnReturn" value="false" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<property name="minEvictableIdleTimeMillis" value="25200000" />
<property name="removeAbandoned" value="false" />
<property name="removeAbandonedTimeout" value="1800" />
<property name="logAbandoned" value="true" />
<!-- <property name="filters" value="stat" /> -->
</bean>
<!-- JDBC模版 -->
<bean id="jdbcTemplate" class="org.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean class="jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory" class="jpa.LocalContainerEntityManagerFactoryBean">  <property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.eshore" />
<property name="jpaVendorAdapter">
<bean class="jpa.vendor.HibernateJpaVendorAdapter">
</bean>
</property>
</bean>
<!-- 配置 JPA Transaction -->
<bean id="transactionManager" class="jpa.JpaTransactionManager">
<property name="jpaDialect">
<bean class="jpa.vendor.HibernateJpaDialect"></bean>
</property>
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- 配置 Annotation 驱动,定义事务-->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。