??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV电影院在线观看,亚洲国产成人久久,亚洲小说区图片区 http://www.tkk7.com/miaoyachun/zh-cn Wed, 02 Jul 2025 14:43:19 GMT Wed, 02 Jul 2025 14:43:19 GMT 60 Spring boot外部配置-配置中心?/title> http://www.tkk7.com/miaoyachun/archive/2017/12/08/432940.htmlMilo的v?/dc:creator>Milo的v?/author>Fri, 08 Dec 2017 06:13:00 GMT http://www.tkk7.com/miaoyachun/archive/2017/12/08/432940.html http://www.tkk7.com/miaoyachun/comments/432940.html http://www.tkk7.com/miaoyachun/archive/2017/12/08/432940.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/432940.html http://www.tkk7.com/miaoyachun/services/trackbacks/432940.html /** * 重蝲合ƈ属性实?br /> * 先加载file propertiesQ?然后q入ZK配置中心d的properties * * @return 合ƈ后的属性集?br /> * @throws IOException 异常 */ @Override protected Properties mergeProperties () throws IOException { Properties result = new Properties(); // 加蝲父类的配|?br /> Properties mergeProperties = super .mergeProperties(); result.putAll(mergeProperties); // 加蝲从zk中读取到的配|?br /> Map<String, String> configs = loadZkConfigs(); result.putAll(configs); return result; } q个实现在spring目里用hq是挺顺手的, 但是q期部分spring-boot目里发现这Uplaceholder的实现跟spring boot的@ConfigurationProperties(prefix = "xxx") 不能很好的配合工? 也就是属性没有被resolve处理, 用@Value的方式确可以d, 但是@Value配置h如果属性多的话q是挺繁琐的, q是們用@ConfigurationProperties的prefix, 于是看了下spring boot的文发?code>PropertySource order:
* Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active). * @TestPropertySource annotations on your tests. * @SpringBootTest#properties annotation attribute on your tests. * Command line arguments. * Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property) * ServletConfig init parameters. * ServletContext init parameters. * JNDI attributes from java:comp/env. * Java System properties (System.getProperties()). * OS environment variables. * A RandomValuePropertySource that only has properties in random.*. * Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants) * Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants) * Application properties outside of your packaged jar (application.properties and YAML variants). * Application properties packaged inside your jar (application.properties and YAML variants). * @PropertySource annotations on your @Configuration classes. * Default properties (specified using SpringApplication.setDefaultProperties).
不难发现其会查Java system propeties里的属? 也就是说, 只要把mergerPropertiesd的属性写入Java system props里即? 看了下源? 扑ֈ个切入点/** * 重蝲处理属性实?br /> * Ҏ选项, 军_是否合q后的props写入pȝ属? Spring boot需?br /> * * @param beanFactoryToProcess * @param props 合ƈ后的属?br /> * @throws BeansException */ @Override protected void processProperties (ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { // 原有逻辑 super .processProperties(beanFactoryToProcess, props); // 写入到系l属?br /> if (writePropsToSystem ) { // write all properties to system for spring boot Enumeration<?> propertyNames = props.propertyNames(); while (propertyNames.hasMoreElements()) { String propertyName = (String) propertyNames.nextElement(); String propertyValue = props.getProperty(propertyName); System.setProperty (propertyName, propertyValue); } } } 为避免媄响过? 讄了个开? 是否写入pȝ属? 如果是spring boot的项? 开? q样对线上非spring boot目做到影响最? 然后spring boot的@ConfigurationProperties完美d属? 具体代码? org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor@Override public Object postProcessBeforeInitialization (Object bean, String beanName) throws BeansException { ConfigurationProperties annotation = AnnotationUtils .findAnnotation (bean.getClass(), ConfigurationProperties .class ); if (annotation != null ) { postProcessBeforeInitialization(bean, beanName, annotation); } annotation = this .beans .findFactoryAnnotation(beanName, ConfigurationProperties .class ); if (annotation != null ) { postProcessBeforeInitialization(bean, beanName, annotation); } return bean; } ]]> Junit @AfterClass讉K注入对象的方?/title> http://www.tkk7.com/miaoyachun/archive/2017/04/15/432461.htmlMilo的v?/dc:creator>Milo的v?/author>Sat, 15 Apr 2017 02:32:00 GMT http://www.tkk7.com/miaoyachun/archive/2017/04/15/432461.html http://www.tkk7.com/miaoyachun/comments/432461.html http://www.tkk7.com/miaoyachun/archive/2017/04/15/432461.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/432461.html http://www.tkk7.com/miaoyachun/services/trackbacks/432461.html S pring默认不允许对cȝ变量, 也就是静态变量进行注入操? 但是在某些场景比如单元测试的@AfterClass要访问注入对? 而Junit的这个方法必L静态的, 也就产生了悖?解决思\有两?
思\1: 惛_法对静态变量注? 也就是绕qSpring只能q行非静态变量才能注入依赖的壁垒
思\2: 惛_法@AfterClass攚wؓ非静?/span>
实现Junit RunListener, 覆盖testRunFinishedҎ, q里d现类似@AfterClass的功? q个Ҏ是非静态的
不要用Junit, 改用TestNG, TestNG里的AfterClass是非静态的
用Spring的TestExecutionListeners, 实现个Listener, 里面也有个类似非静态的AfterClass的实? 覆盖实现p
思\2的几个方法都可以实现, 但是单元试Runner需要用
而且改用TestNG工程大, 只能攑ּ掉这个思\
l箋走思\1, 只能ȝqSpring的依赖注入的static壁垒? 具体代码如下:
@Autowired
private Destination dfsOperationQueue ;
private static Destination dfsOperationQueueStatic ; // static version
@Autowired
private MessageQueueAPI messageQueueAPI ;
private static MessageQueueAPI messageQueueAPIStatic ; // static version
@PostConstruct
public void init () {
dfsOperationQueueStatic = this . dfsOperationQueue ;
messageQueueAPIStatic = this . messageQueueAPI ;
}
@AfterClass
public static void afterClass () {
MessageVO messageVO = messageQueueAPIStatic . removeDestination ( dfsOperationQueueStatic );
System . out . println ( messageVO );
}
其实是用了@PostConstruct 来个h换柱而已, 多声明个静态成员指向非静态对? 两者其实是一个对?/span>
]]> 通过rest api理activemq http://www.tkk7.com/miaoyachun/archive/2016/10/22/431914.htmlMilo的v?/dc:creator>Milo的v?/author>Sat, 22 Oct 2016 09:31:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/10/22/431914.html http://www.tkk7.com/miaoyachun/comments/431914.html http://www.tkk7.com/miaoyachun/archive/2016/10/22/431914.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/431914.html http://www.tkk7.com/miaoyachun/services/trackbacks/431914.html 知道activemq现在已经支持了rest api, 但是官方对这部分的介l一W带q?(http://activemq.apache.org/rest.html),
通过google居然也没搜到一些有用的, 比如像删除一个destination, 都是问的?然后没下? 于是׃一些心思研I了一?
首先通过rest api获取当前版本所有已支持的协?/p>
http://172.30.43.206:8161/api/jolokia/list
然后Ҏjson输出关于removeTopic, removeQueue的mbean实现通过rest api删除destination的方? 注意到用GETh而不是POST,不然会报?(官网的例子里用的wgetl的灉|, 开始用了POST老报?
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.DefaultHttpClient; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; import javax.jms.Destination; import javax.jms.JMSException; import java.util.Arrays; public class MessageQueueAdmin { private static final RestTemplate restTemplate = getRestTemplate( " admin " , " admin " ); private static String brokerHost = " 172.30.43.206 " ; private static String adminConsolePort = " 8161 " ; private static String protocol = " http " ; public static void removeDestination(Destination destination) throws JMSException { String destName, destType; if (destination instanceof ActiveMQQueue) { destName = ((ActiveMQQueue) destination).getQueueName(); destType = " Queue " ; } else { destName = ((ActiveMQTopic) destination).getTopicName(); destType = " Topic " ; } // build urls String url = String.format( " %s://%s:%s/api/jolokia/exec/org.apache.activemq: " + " brokerName=localhost,type=Broker/remove%s/%s " , protocol, brokerHost, adminConsolePort, destType, destName); System.out.println(url); // do operation HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); HttpEntity < String > entity = new HttpEntity < String > ( " parameters " , headers); ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, String. class ); System.out.println(response.getBody()); } public static void main(String[] args) throws JMSException { ActiveMQTopic topic = new ActiveMQTopic( " test-activemq-topic " ); removeDestination(topic); } private static RestTemplate getRestTemplate(String user, String password) { DefaultHttpClient httpClient = new DefaultHttpClient(); BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, password)); httpClient.setCredentialsProvider(credentialsProvider); ClientHttpRequestFactory rf = new HttpComponentsClientHttpRequestFactory(httpClient); return new RestTemplate(rf); } }
其他的请?应该都是cMjolokia的exec get request的格?
https://jolokia.org/reference/html/protocol.html#exec
<base url>/exec/<mbean name>/<operation name>/<arg1>/<arg2>/ . ]]>JmsTemplate CLIENT_ACKNOWLEDGE 模式下receive消息的问?/title> http://www.tkk7.com/miaoyachun/archive/2016/10/12/431885.htmlMilo的v?/dc:creator>Milo的v?/author>Wed, 12 Oct 2016 08:32:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/10/12/431885.html http://www.tkk7.com/miaoyachun/comments/431885.html http://www.tkk7.com/miaoyachun/archive/2016/10/12/431885.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/431885.html http://www.tkk7.com/miaoyachun/services/trackbacks/431885.html protected Message doReceive(Session session, MessageConsumer consumer) throws JMSException { try { // Use transaction timeout (if available). long timeout = getReceiveTimeout(); JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager.getResource(getConnectionFactory()); if (resourceHolder != null && resourceHolder.hasTimeout()) { timeout = Math.min(timeout, resourceHolder.getTimeToLiveInMillis()); } Message message = doReceive(consumer, timeout); if (session.getTransacted()) { // Commit necessary - but avoid commit call within a JTA transaction. if (isSessionLocallyTransacted(session)) { // Transacted session created by this template -> commit. JmsUtils.commitIfNecessary(session); } } else if (isClientAcknowledge(session)) { // Manually acknowledge message, if any. if (message != null ) { message.acknowledge(); } } return message; } finally { JmsUtils.closeMessageConsumer(consumer); } }
但是使用异步listener ׃会出现这个情况,搜了下googleQ发现果然存在这个问?br /> https://jira.spring.io/browse/SPR-12995 https://jira.spring.io/browse/SPR-13255 http://louisling.iteye.com/blog/241073
同步方式拉取消息Q暂时没扑ֈ好的装Q只能暂时用q。或者尽量用listener, q个问题暂时标记下,或者谁有更好的解决Ҏ可以comment?img src ="http://www.tkk7.com/miaoyachun/aggbug/431885.html" width = "1" height = "1" /> ]]> 树莓z?B完美匚wDELL P2014H的配|?/title> http://www.tkk7.com/miaoyachun/archive/2016/06/15/430904.htmlMilo的v?/dc:creator>Milo的v?/author>Wed, 15 Jun 2016 01:32:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/06/15/430904.html http://www.tkk7.com/miaoyachun/comments/430904.html http://www.tkk7.com/miaoyachun/archive/2016/06/15/430904.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/430904.html http://www.tkk7.com/miaoyachun/services/trackbacks/430904.html 默认的配|有时候点不亮昄器,且分辨率很低Q通过tvservice工具不断调试Q发C面的参数可以完美匚w?br />修改 /boot/config.txt的下列参?/div> disable_overscan = 1 hdmi_force_hotplug= 1 hdmi_group= 1 hdmi_mode= 16 hdmi_drive= 2 config_hdmi_boost= 4 dtparam= audio = on
]]> Spring中classpath与classpath*的区?/title> http://www.tkk7.com/miaoyachun/archive/2016/05/26/430666.htmlMilo的v?/dc:creator>Milo的v?/author>Thu, 26 May 2016 06:14:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/05/26/430666.html http://www.tkk7.com/miaoyachun/comments/430666.html http://www.tkk7.com/miaoyachun/archive/2016/05/26/430666.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/430666.html http://www.tkk7.com/miaoyachun/services/trackbacks/430666.html http://stackoverflow.com/questions/3294423/spring-classpath-prefix-difference
SIMPLE DEFINITION The classpath*:conf/appContext.xml simply means that all appContext.xml files under conf folders in all your jars on the classpath will be picked up and joined into one big application context. In contrast, classpath:conf/appContext.xml will load only one such file the first one found on your classpath. < bean id ="propertyConfigurer" class ="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > < property name ="locations" > < list > < value > classpath:*.properties</ value > < value > classpath*:*.properties</ value > </ list > </ property > </ bean > ]]> When launched from .exe IDEA looks for Java in a following order http://www.tkk7.com/miaoyachun/archive/2016/05/16/430516.htmlMilo的v?/dc:creator>Milo的v?/author>Mon, 16 May 2016 00:49:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/05/16/430516.html http://www.tkk7.com/miaoyachun/comments/430516.html http://www.tkk7.com/miaoyachun/archive/2016/05/16/430516.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/430516.html http://www.tkk7.com/miaoyachun/services/trackbacks/430516.html IDEA_JDK (or IDEA_JDK_64) environment variable jre/ (or jre64/) directory in IDEA home registry JDK_HOME environment variable JAVA_HOME environment variable ]]> java修改stdout的历史输?/title> http://www.tkk7.com/miaoyachun/archive/2016/04/21/430179.htmlMilo的v?/dc:creator>Milo的v?/author>Thu, 21 Apr 2016 09:06:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/04/21/430179.html http://www.tkk7.com/miaoyachun/comments/430179.html http://www.tkk7.com/miaoyachun/archive/2016/04/21/430179.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/430179.html http://www.tkk7.com/miaoyachun/services/trackbacks/430179.html ANSI code 用java写了个简单的例子Q例子就是把曄的output修改为其他字W串q恢复之后的打印Q代码里加了sleepQ主要方便理解各U控制序列的含义 // print some test messages System.out.println( " 1 " ); Thread.sleep( 1000 ); System.out.println( " 22 " ); Thread.sleep( 1000 ); System.out.println( " 333 " ); Thread.sleep( 1000 ); System.out.println( " 4444 " ); Thread.sleep( 1000 ); /** * modify "333" to "-" */ // Move up two lines int count = 2 ; System.out.print(String.format( " \033[%dA " , count)); Thread.sleep( 1000 ); // Erase current line content System.out.print( " \033[2K " ); Thread.sleep( 1000 ); // update with new content System.out.print( " - " ); Thread.sleep( 1000 ); // Move down two lines System.out.print(String.format( " \033[%dB " , count)); Thread.sleep( 1000 ); // Move cursor to left beginning System.out.print(String.format( " \033[D " , count)); // continue print others Thread.sleep( 1000 ); System.out.println( " 55555 " ); Thread.sleep( 1000 );
]]> zookeeper学习 http://www.tkk7.com/miaoyachun/archive/2016/03/31/429913.htmlMilo的v?/dc:creator>Milo的v?/author>Thu, 31 Mar 2016 06:06:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/03/31/429913.html http://www.tkk7.com/miaoyachun/comments/429913.html http://www.tkk7.com/miaoyachun/archive/2016/03/31/429913.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/429913.html http://www.tkk7.com/miaoyachun/services/trackbacks/429913.html 2. 详细介绍 http://blog.csdn.net/xhh198781/article/details/10949697 ]]> Spring boot 开启reponse压羃以及部分参数讄 http://www.tkk7.com/miaoyachun/archive/2016/03/29/429861.htmlMilo的v?/dc:creator>Milo的v?/author>Tue, 29 Mar 2016 03:50:00 GMT http://www.tkk7.com/miaoyachun/archive/2016/03/29/429861.html http://www.tkk7.com/miaoyachun/comments/429861.html http://www.tkk7.com/miaoyachun/archive/2016/03/29/429861.html#Feedback 0 http://www.tkk7.com/miaoyachun/comments/commentRss/429861.html http://www.tkk7.com/miaoyachun/services/trackbacks/429861.html server.compression.enabled =true server.compression.mime-types =application/json,application/xml,text/html,text/xml,text/plain server.compression.min-response-size =4096 W一个参数打开压羃开养IW二个参数添加json reponseQ尤其是为rest apiQ?W三个参数是Ҏreponse的大设|启用压~的最?默认?KQ自己根据实际情况调? 参?div>http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#how-to-enable-http-response-compression ]]>
վ֩ģ壺
Ʒһߵ |
97ѹۿƵ߹ۿ |
Ʒɫ99þþƷ |
Ƶ߹ۿѲӰԺ |
ˬִ̼վֱ
|
߹ۿƵվɫ |
91ֻƷѹۿ |
վ |
þþƷAVɫ |
߹ۿһ |
߹ۿһëƬ |
ҹƷƬ |
һ˿wwwƵ
|
crmϵͳz
|
MM1313Ʒ |
ձ߿Ƭ˳Ƶ1000 |
ӰƵѹۿ |
ƷպAVһ
|
avŮӰ |
ձŷɫƵ߲ |
ѹۿaƬ |
AVҹ丣㽶149 |
AVһ
|
ɫ͵͵Ůùۿŷ |
˿wwwƵ |
AVƬ߹ۿ |
Ůѹۿվh |
ƷAVһ |
ŮƵվ |
ഺɫУС˵ |
wwwƵ |
ƷƵ |
ҹĻƷվ
|
av߹ۿվ |
ݽվƵ |
Ʒþþþ |
йһػƵƬ
|
ۺϾƷһ |
ɫóվ߹ۿ
|
ƷۺϾþþ |
ѹۿëƬ |