本篇介绍一些Spring与其它框架结合的有用功能,包含:Apache CXF WebService框架、Redis缓存、RabbitMQ消息、MyBatis框架。

另外对于Profile,也是Spring3.0開始新加的功能,对于开发測试环境、和生产环境分别採用不同的配置,有一定用处。

Profile

Spring3.1新属性管理API:PropertySource、Environment、Profile。

Environment:环境。本身是一个PropertyResolver,可是提供了Profile特性,即能够依据环境得到对应数据(即激活不同的Profile。能够得到不同的属性数据,比方用于多环境场景的配置(正式机、測试机、开发机DataSource配置))。

Profile:剖面,仅仅有激活的剖面的组件/配置才会注冊到Spring容器,类似于maven中profile。Spring 3.1添加了一个在不同环境之间简单切换的profile概念, 能够在不改动不论什么文件的情况下让project分别在 dev/test/production 等环境下执行。

为了减小部署维护,能够让project会默认执行在dev模式,而測试环境和生产环境通过添加jvm參数激活 production的profile.

比方。对于例如以下的一个样例。因为測试环境和生产环境,连接数据库的方式不一样。能够有例如以下的解决的方法:

1、首先ApplicationContext.xml中,xsi:schemaLocation须要引用3.2的xsd

2、ApplicationContext.xml配置例如以下:

  1. <beans profile="production">
  2. <bean id="dataSourcejdbc" class="org.springframework.jndi.JndiObjectFactoryBean">
  3. <property name="jndiName" value="java:/MySqlDS_JDBC" />
  4. </bean>
  5. </beans>
  6. <beans profile="dev">
  7. <bean id="dataSourcejdbc" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  8. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  9. <property name="url" value="jdbc:mysql://IP:3306/db?characterEncoding=utf-8"/>
  10. <property name="username" value="root"/>
  11. <property name="password" value="root"/>
  12. </bean>
  13. </beans>

3、开发环境配置。在web.xml中,例如以下配置:

  1. <context-param>
  2. <param-name>spring.profiles.default</param-name>
  3. <param-value>dev</param-value>
  4. </context-param>

4、生产环境配置

比方,对于Jboss,在bin/run.conf里面。添加启动參数:-Dspring.profiles.active=production

JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MaxPermSize=1024m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true -Dorg.terracotta.quartz.skipUpdateCheck=true
-Dspring.profiles.active=production"

以上是对于Web项目中怎样利用profile的一种演示,假设是maven项目,也能够在maven打包时採用不同的profile。命令例如以下:

mvn clean package -Dmaven.test.skip=true -Ponline

通过P參数採用不同的profile,这样能够实现为开发、測试、生产打出不同的包。

只是。不推荐这样的打包方式。应该是对于开发、測试、生产打出一样的包,然后依据机器本身的环境。来决定程序是依照那种环境来执行。

假设公司有依据环境变量的自己主动化部署方式(比方dev/test/stage/online)。则这个profile是很管用的。

WebService

Java生态下的WebService框架许多,apache cxf 是与spring结合最好的一种。配置过程例如以下:

1、pom.xml,添加依赖:

  1. <dependency>
  2. <groupId>org.apache.cxf</groupId>
  3. <artifactId>cxf-rt-frontend-jaxws</artifactId>
  4. <version>2.7.5</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.cxf</groupId>
  8. <artifactId>cxf-rt-transports-http</artifactId>
  9. <version>2.7.5</version>
  10. </dependency>

2、web.xml。添加servlet:

  1. <!-- Web Service声明開始 -->
  2. <servlet>
  3. <servlet-name>cxf</servlet-name>
  4. <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
  5. <load-on-startup>2</load-on-startup>
  6. </servlet>
  7. <servlet-mapping>
  8. <servlet-name>cxf</servlet-name>
  9. <url-pattern>/*</url-pattern>
  10. </servlet-mapping>
  11. <!-- Web Service声明结束 -->

3、resources文件夹下。添加applicationContext-cxf.xml,内容例如以下:

  1. <?
  2.  
  3. xml version="1.0" encoding="UTF-8"?
  4.  
  5. >
  6. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7. xmlns:jaxws="http://cxf.apache.org/jaxws"
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  9. http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
  10.  
  11. <!-- <import resource="classpath:META-INF/cxf/cxf.xml" />
  12. <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> -->
  13.  
  14. <jaxws:endpoint implementor="#basicWebService" address="/BasicWebService" />
  15. </beans>

4、BasicWebService来的内容大致例如以下:

  1. @WebService(name = "BasicWebService", serviceName = "BasicWebService", portName = "BasicWebServicePort", targetNamespace = "http://api.domain.com/ws")
  2. @Service
  3. public class BasicWebService {
  4. @WebMethod
  5. public void sendHtmlMail(@WebParam(name = "headName") String headName,
  6. @WebParam(name = "sendHtml") String sendHtml) {
  7. sendMail.doSendHtmlEmail(headName, sendHtml);
  8. }
  9. }

使用Apache CXF框架,是被Spring容器管理的,也就是说,BasicWebService本身能够设置@Service标记,也能够在BasicWebService中使用@Autowired进行注入。

而其它框架的WebService。比方Jboss直接通过Servlet方式暴露的WebService就不能这样,仅仅能通过一个SpringContextHolder手动从Spring容器中拿。大致例如以下:

1、首先在web.xml中添加WebService类的servlet。例如以下:

  1. <!-- Web Service声明開始 -->
  2. <servlet>
  3. <servlet-name>BasicWebService</servlet-name>
  4. <servlet-class>com.xx.BasisWebService</servlet-class>
  5. </servlet>
  6. <servlet-mapping>
  7. <servlet-name>BasicWebService</servlet-name>
  8. <url-pattern>/BasicWebService</url-pattern>
  9. </servlet-mapping>
  10. <!-- Web Service声明结束 -->

2、BasicWebService的内容大致例如以下:

  1. @WebService(name = "BasicWebService", serviceName = "BasicWebService", portName = "BasicWebServicePort", targetNamespace = "http://api.sina.com/ws")
  2. public class BasicWebService {
  3.  
  4. //这是从Spring容器中拿对象。SpringContextHolder是一个实现了org.springframework.context.ApplicationContextAware的类
  5. private ISystemConfigService systemConfigService = SpringContextHolder.getBean(ISystemConfigService.class);
  6.  
  7. @WebMethod
  8. public String test(@WebParam(name = "inputpara") String inputpara) {
  9. return inputpara + "_100";
  10. }
  11. }

Redis

Spring能够简化调用Redis的操作。配置大致例如以下:

1、pom.xml添加依赖:

<dependency>

  1. <groupId>org.springframework.data</groupId>
  2. <artifactId>spring-data-redis</artifactId>
  3. <version>1.0.6.RELEASE</version>
  4. </dependency>

2、resources文件夹下,添加applicationContext-redis.xml,内容例如以下:

  1. <?
  2.  
  3. xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:cache="http://www.springframework.org/schema/cache"
  7. xmlns:p="http://www.springframework.org/schema/p"
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  9. http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
  10. <description>Spring-cache</description>
  11. <cache:annotation-driven/>
  12. <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
  13. <constructor-arg name="template" index="0" ref="redisTemplate"/>
  14. </bean>
  15. <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
  16. <property name="maxActive" value="${redis.pool.maxActive}"/>
  17. <property name="maxIdle" value="${redis.pool.maxIdle}"/>
  18. <property name="maxWait" value="${redis.pool.maxWait}"/>
  19. <property name="testOnBorrow" value="${redis.pool.testOnBorrow}"/>
  20. </bean>
  21. <!-- 工厂实现: -->
  22. <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  23. <property name="hostName" value="${redis.ip}"/>
  24. <property name="port" value="${redis.port}"/>
  25. <property name="poolConfig" ref="jedisPoolConfig"/>
  26. </bean>
  27. <!--模板类: -->
  28. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="jedisConnectionFactory">
  29. <property name="keySerializer" ref="stringRedisSerializer"/>
  30. </bean>
  31. <bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
  32. </beans>

3、缓存写入參考实现:

  1. @Service
  2. public class BrandBaseServiceImpl implements IBrandBaseService {
  3. @Override
  4. @Cacheable(value = CacheClientConstant.COMMODITY_BRAND_REDIS_CACHE, key = "'commodity:webservice:all:brand:list'")
  5. public List<Brand> getAllBrands() {
  6. try
  7. {
  8. List<Brand> brands = brandMapper.getAllBrands();
  9. return brands;
  10. } catch (Exception ex)
  11. {
  12. logger.error(ex.toString());
  13. return null;
  14. }
  15. }
  16. @Override
  17. @Cacheable(value = CacheClientConstant.COMMODITY_BRAND_REDIS_CACHE, key = "'commodity:webservice:brand:no:'+#brandNo")
  18. public Brand getBrandByNo(String brandNo) {
  19. if (StringUtils.isBlank(brandNo))
  20. return null;
  21. return brandMapper.getBrandByNo(brandNo);
  22. }
  23. }

4、缓存清除參考实现:

  1. @Service
  2. public class RedisCacheUtil {
  3.  
  4. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  5. @Autowired
  6. private RedisTemplate<String,Object> redisTemplate;
  7. @Autowired
  8. private JedisConnectionFactory jedisConnectionFactory;
  9. @CacheEvict(value = CacheClientConstant.COMMODITY_CATEGORY_REDIS_CACHE, key = "'commodity:webservice:category:no:'+#categoryNo")
  10. public void cleanCatCacheByNo(String categoryNo)
  11. {
  12. List<String> keys = new ArrayList<String>();
  13. logger.info("[商品服务端]清理分类categoryNo:{}缓存,REDIS SERVER地址:{}", categoryNo, jedisConnectionFactory.getHostName() + ":" + jedisConnectionFactory.getPort());
  14. if (StringUtils.hasText(categoryNo)) {
  15. keys.add("commodity:webservice:category:no:" + categoryNo);
  16. cleanAgain(keys);
  17. }
  18. }
  19. @CacheEvict(value = CacheClientConstant.COMMODITY_SYSTEMCONFIG_REDIS_CACHE, allEntries = true)
  20. public void cleanSystemConfigAll()
  21. {
  22. logger.info("[商品服务端]清楚SystemConfig缓存");
  23. }
  24. /**
  25. * 考虑到主从延迟可能会导致缓存更新失效。延迟再清理一次缓存
  26. * @param keys 须要清除缓存的KEY
  27. */
  28. private void cleanAgain(List<String> keys) {
  29. if (CollectionUtils.isEmpty(keys)) {
  30. return;
  31. }
  32. for (String key : keys) {
  33. logger.info("清理缓存,KEY:{}", key);
  34. redisTemplate.delete(key);
  35. }
  36. }
  37. }

RabbitMQ

Spring也能够简化使用RabbitMQ的操作,配置大致例如以下:

1、pom.xml添加依赖:

  1. <dependency>
  2. <groupId>org.springframework.amqp</groupId>
  3. <artifactId>spring-amqp</artifactId>
  4. <version>${spring.amqp.version}</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.amqp</groupId>
  8. <artifactId>spring-rabbit</artifactId>
  9. <version>${spring.amqp.version}</version>
  10. </dependency>

2、发送消息代码样例:

  1. @Service
  2. public class MessageSendServiceImpl implements IMessageSendService {
  3. private static final String EXCHANGE = "amq.topic";
  4. @Autowired
  5. private volatile RabbitTemplate rabbitTemplate;
  6. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  7. @Override
  8. public Boolean sendMessage(String commodityNo) {
  9. Commodity c = getCommodity(commodityNo);
  10. // 发送rabbitMQ消息(topic)
  11. rabbitTemplate.convertAndSend(EXCHANGE, "commodity.update.topic", c);
  12. logger.info("发送消息成功(topic):商品编号:" + commodityNo);
  13. return true;
  14. }
  15. }

3、resources文件夹下。添加applicationContext-rabbitmq.xml,用来配置接收消息,内容例如以下:

  1. <?
  2.  
  3. xml version="1.0" encoding="UTF-8"?
  4.  
  5. >
  6. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7. xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:task="http://www.springframework.org/schema/task"
  8. xmlns:context="http://www.springframework.org/schema/context"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.1.xsd
  11. http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
  12. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
  13. <!-- 定义rabbitmq连接工厂。生产环境使用集群配置。支持failoverrabbitmq.host=192.168.211.230:5672 -->
  14. <rabbit:connection-factory id="connectionFactory" addresses="${rabbitmq.host}" />
  15. <rabbit:admin connection-factory="connectionFactory" />
  16. <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" channel-transacted="true"
  17. message-converter="jsonMessageConverter" />
  18. <bean id="jsonMessageConverter" class="org.springframework.amqp.support.converter.JsonMessageConverter">
  19. <property name="classMapper">
  20. <bean class="org.springframework.amqp.support.converter.DefaultClassMapper">
  21. </bean>
  22. </property>
  23. </bean>
  24. <!--
  25. 两种业务需求:
  26. 1. 同一个服务部署在多台server上,假设想消息被一个服务收取,则要配置name,<rabbit:listener 里的queues=这里的name
  27. 2. 同一个服务部署在多台server上,假设想消息被全部的服务收取,刚不要配置name。用rabbitmq自己主动创建的匿名name。这时要去掉这里的name属性, 而且<rabbit:listener里的queues=这里的id
  28. 一般来说。都是第一种业务需求较多
  29. -->
  30. <rabbit:queue id="queue的id,能够和name一样" name="queue的名字,在rabbitmq控制台能够看到,比如commodity.update.topic.queue">
  31. <rabbit:queue-arguments>
  32. <entry key="x-ha-policy" value="all" />
  33. </rabbit:queue-arguments>
  34. </rabbit:queue>
  35. <!-- CONSUMER -->
  36. <!-- 这里的error-handler最好都配置。由于rabbitmq报的异常默认是不被捕获的。假设这里没有error-handler,log级别又没指定到amqp的包,那么错误将不会被察觉 -->
  37. <rabbit:listener-container connection-factory="connectionFactory" message-converter="jsonMessageConverter"
  38. channel-transacted="true" error-handler="rabbitMqErrorHandler" concurrency="10"
  39. auto-startup="true">
  40. <rabbit:listener queues="rabbit:queue中定义的name或者id" ref="commodityUpdateListener" method="handleMessage" />
  41. </rabbit:listener-container>
  42. <rabbit:topic-exchange name="amq.topic" >
  43. <rabbit:bindings>
  44. <!-- 这里的queue是<rabbit:queue 里的ID -->
  45. <rabbit:binding pattern="发送方的routingKey。对于上面的发送就是commodity.update.topic" queue="queue的名字,在rabbitmq控制台能够看到。比如commodity.update.topic.queue"/>
  46. </rabbit:bindings>
  47. </rabbit:topic-exchange>
  48. </beans>

4、接收消息代码样例:

  1. @Component
  2. public class CommodityUpdateListener {
  3. public void handleMessage(Commodity commodity) {
  4. if(commodity==null)
  5. {
  6. logger.info("XXX");
  7. return;
  8. }
  9. //处理逻辑
  10. }
  11. }

5、处理消息错误代码样例:

  1. @Component
  2. public class RabbitMqErrorHandler implements ErrorHandler {
  3.  
  4. private static Logger logger = LoggerFactory.getLogger(RabbitMqErrorHandler.class);
  5.  
  6. @Override
  7. public void handleError(Throwable t) {
  8. logger.error("Receive rabbitmq message error:{}", t);
  9. }
  10. }

MyBatis

Spring能够大大简化使用MyBatis这样的ORM框架,定义出接口和Mapper文件之后。Spring能够自己主动帮我们生成实现类。

我以前在DotNet框架下使用过MyBatis.Net,全部的Mapper的实现类都须要手工写代码,而Spring帮我节省了非常多编码工作量。

大致配置过程例如以下:

1、pom.xml添加依赖:

  1. <dependency>
  2. <groupId>org.mybatis</groupId>
  3. <artifactId>mybatis-spring</artifactId>
  4. <version>1.1.1</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.mybatis.caches</groupId>
  8. <artifactId>mybatis-ehcache</artifactId>
  9. <version>1.0.1</version>
  10. </dependency>

2、resources文件夹下,applicationContext.xml中。一般放置关于mybatis的配置,内容例如以下:

  1. <?
  2.  
  3. xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
  6. xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task"
  7. xmlns:aop="http://www.springframework.org/schema/aop"
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  9. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  10. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
  11. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
  12. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
  13. <description>Spring公共配置</description>
  14. <!--开启注解 -->
  15. <context:annotation-config />
  16. <!-- 开启自己主动切面代理 -->
  17. <aop:aspectj-autoproxy />
  18. <context:component-scan base-package="com.xx">
  19. <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  20. </context:component-scan>
  21. <!-- 定义受环境影响易变的变量 -->
  22. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  23. <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
  24. <property name="ignoreResourceNotFound" value="true" />
  25. <property name="locations">
  26. <list>
  27. <!-- 标准配置 -->
  28. <value>classpath*:/application.properties</value>
  29. <value>classpath*:/config.properties</value>
  30. <!-- 本地开发环境配置 -->
  31. <value>file:/d:/conf/pcconf/*.properties</value>
  32. <!-- server生产环境配置 -->
  33. <value>file:/etc/conf/pcconf/*.properties</value>
  34. </list>
  35. </property>
  36. <!--property name="ignoreUnresolvablePlaceholders" value="true" / -->
  37. </bean>
  38. <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
  39. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  40. <property name="dataSource" ref="dataSourcejdbc"/>
  41. </bean>
  42. <!-- 强烈建议用JdbcTemplate取代JdbcUtils -->
  43. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  44. <property name="dataSource" ref="dataSourcejdbc" />
  45. </bean>
  46. <bean id="sqlSessionFactoryWrite" class="org.mybatis.spring.SqlSessionFactoryBean">
  47. <property name="dataSource" ref="dataSourcejdbc" />
  48. </bean>
  49. <!-- 会自己主动将basePackage中配置的包路径下的全部带有@Mapper标注的Dao层的接口生成代理,替代原来我们的Dao实现。
  50.  
  51. -->
  52. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  53. <property name="sqlSessionFactory" ref="sqlSessionFactoryWrite" />
  54. <property name="basePackage" value="com/xx/pc/template" />
  55. </bean>
  56. <beans profile="production">
  57. <bean id="dataSourcejdbc" class="org.springframework.jndi.JndiObjectFactoryBean">
  58. <property name="jndiName" value="java:/MySqlDS_JDBC" />
  59. </bean>
  60. </beans>
  61. <beans profile="dev">
  62. <bean id="dataSourcejdbc" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  63. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  64. <property name="url" value="jdbc:mysql://ip:3306/dbname?
  65.  
  66. characterEncoding=utf-8"/>
  67. <property name="username" value="root"/>
  68. <property name="password" value="root"/>
  69. </bean>
  70. </beans>
  71. </beans>

3、定义接口,及在src/main/resource相应接口的包路径下定义同名的xml配置文件就可以。

Spring初始化完成后,会自己主动帮我们生成Mapper的实现类。

Spring有用功能--Profile、WebService、缓存、消息、ORM的更多相关文章

  1. Spring boot 的profile功能如何实现多环境配置自动切换

    通常服务端应用开发需要经过以下几个流程: 开发 -> 测试 -> RC验证 -> 上线 这就涉及到四个不同的环境,开发环境.测试环境.RC环境以及生产环境,为了避免不同环境之间相互干 ...

  2. [Spring Boot 系列] 集成maven和Spring boot的profile功能

    由于项目的需要, 今天给spirng boot项目添加了profile功能.再网上搜索了一圈,也没有找到满意的参考资料,其实配置并不难,就是没有一个one stop(一站式)讲解的地方,所以有了写这篇 ...

  3. 004-集成maven和Spring boot的profile功能打包

    参考地址:https://blog.csdn.net/lihe2008125/article/details/50443491 一.主要目标 1.通过mvn在命令行中打包时,可以指定相应的profil ...

  4. 第5章 Spring Boot 功能

    Spring Boot 功能 本节将会介绍Spring Boot的一些细节. 在这里,您可以了解您将要使用和自定义的主要功能. 如果还没有准备好,您可能需要阅读第二部分“入门指南”和第三部分“使用 S ...

  5. 集成maven和Spring boot的profile 专题

    maven中配置profile节点: <project> .... <profiles> <profile> <!-- 生产环境 --> <id& ...

  6. [Spring Boot 系列] 集成maven和Spring boot的profile 专题

    maven中配置profile节点: <project> .... <profiles> <profile> <!-- 生产环境 --> <id& ...

  7. 集成maven和Spring boot的profile

    如果在配置中勾选了多套配置,则以pom.xml文件中 profiles中  配置 最后一个配置为准. maven中配置profile节点: <project> .... <profi ...

  8. [02] Spring主要功能模块概述

    1.Spring主要功能模块   1.1 Core Container Spring的核心容器模块,其中包括: Beans Core Context SpEL Beans和Core模块,是框架的基础部 ...

  9. ActiveMQ5.0实战三:使用Spring发送,消费topic和queue消息

    实战一 , 实战二 介绍了ActiveMQ的基本概念和配置方式. 本篇将通过一个实例介绍使用spring发送,消费topic, queue类型消息的方法. 不懂topic和queue的google 之 ...

随机推荐

  1. [POI2010]KLO-Blocks(单调栈)

    题意 给出N个正整数a[1..N],再给出一个正整数k,现在可以进行如下操作:每次选择一个大于k的正整数a[i],将a[i]减去1,选择a[i-1]或a[i+1]中的一个加上1.经过一定次数的操作后, ...

  2. caioj 1111 树形动态规划(TreeDP)6: 皇宫看守 (状态设计)

    这道题的难点在于状态怎么设计 这道题要求全部都是安全的,所以我们做的时候自底向上每一个结点都要是安全的 结合前一题当前结点选和不选,我们可以分出四种情况出来 选 安全 选 不安全 不选 安全 不选 不 ...

  3. 关于memset赋最值

    出处[辗转山河弋流歌 by 空灰冰魂] blog.csdn.net/vmurder/article/details/46537613 memset(a, 0x3f, sizeof(a)) //int, ...

  4. 一 SSH 无密码登陆 & Linux防火墙 & SELinux关闭

    如果系统环境崩溃.   调用/usr/bin/vim /etc/profile   SHH无密码登陆 所有要做得节点上运行   修改 host name vi /etc/sysconfig/netwo ...

  5. 数据迁移工具kettle简单上手

    近期做了不少数据迁移工作,无一例外都是kettle做的,对于这些工具,我认为.够用就好,不用做特别多的研究(当然.除非你是这款工具的忠实粉丝,我相信这种没几个).kettle也不例外.在我看来就是不同 ...

  6. 《SAS编程与数据挖掘商业案例》学习笔记之十八

    接着曾经的<SAS编程与数据挖掘商业案例>,之前全是sas的基础知识,如今開始进入数据挖掘方面笔记,本文主要介绍数据挖掘基本流程以及应用方向,并以logistic回归为例说明. 一:数据挖 ...

  7. Struts2 全局结果集

    1.index,jsp <body> Result类型 <ol> <li><a href="user/user?type=1">返回 ...

  8. 无法往SQL Server Management Studio拖脚本

    解决方法:不要用Administrator权限打开sql server

  9. apiCloud手动检测更新

    有时候需要给用户一个自主的权利,自主检测app是否是最新版本. 如何实现? 1.点击调用接口,检测是否有更新. 默认APICloud会自动检测版本更新,用户也可以在config.xml里配置autoU ...

  10. html 下载文件代码

    首先在html中加个a标签 <a class="menu" href="/cmdb/file_down" download="ljctest.t ...