尝试运行可执行jar文件时,我正面临"循环占位符引用"异常.这是详细的例外.
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'postProcessProperties' defined in class path resource [applicationContext.xml]: Circular placeholder reference 'processor.core.poolsize' in property definitions
[echo] at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
[echo] at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
[echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
[echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
[echo] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
[echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
[echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
[echo] at com.autodesk.postprocess.engine.PostProcessEngine.start(PostProcessEngine.java:39)
[echo] at com.autodesk.postprocess.engine.PostProcessEngine.main(PostProcessEngine.java:29)
Run Code Online (Sandbox Code Playgroud)
这是一个spring应用程序,它使用外部属性文件在启动时读取值.这是春天的定义.到目前为止,这种方法运作良好.
<bean id="propertyConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_NEVER" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:/postprocess.properties</value>
</list>
</property>
<property name="properties">
<props>
<prop key="processor.core.poolsize">${processor.core.poolsize}</prop>
<prop key="processor.max.poolsize">${processor.max.poolsize}</prop>
</props>
</property>
</bean>
<bean id="postProcessProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property …Run Code Online (Sandbox Code Playgroud) 我是DynamoDB的新手,并尝试使用Transaction支持的示例场景.我正在使用dynamodb-transaction库中提供的相同实体.唯一的区别是我用散列键添加了一个范围键.这是表定义:
ItemId - >哈希键,字符串ItemName - >范围键,字符串@DynamoDBTable(tableName = "Item")
public static class ExampleItem {
private String itemId;
private String value;
private String itemName;
private Long version;
@DynamoDBHashKey(attributeName = "ItemId")
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
@DynamoDBRangeKey(attributeName="ItemName")
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value; …Run Code Online (Sandbox Code Playgroud) 只是想找到一种方法将Dom4J Document内容转换为String.它有一个asXML() API,可以将内容转换为XML.在我的例子中,我正在使用Dom4J编辑非xml DOM结构并尝试将内容转换为String.我知道w3c文件的可能性.
任何指针将不胜感激.
谢谢
我有一个要求,在将日期索引到Solr之前,可以使用以下格式传递日期.以下是传递日期的示例
String dateStr = "2012-05-23T00:00:00-0400";
String dateStr1 = "May 24, 2012 04:57:40 GMT";
String dateStr2 = "2011-06-21";
Run Code Online (Sandbox Code Playgroud)
标准的Solr格式是"yyyy-MM-dd'T'HH:mm:ss'Z'".
我尝试过SimpleDateFormat,但是无法编写支持各种格式的通用程序.它最终会抛出解析异常.
我也尝试过joda时间,但到目前为止还没有成功进行UTC转换.
public static String toUtcDate(final String iso8601) {
DateTime dt = ISO_PARSE_FORMAT.parseDateTime(iso8601);
DateTime utcDt = dt.withZone(ZONE_UTC);
return utcDt.toString(ISO_PRINT_FORMAT);
}Run Code Online (Sandbox Code Playgroud)
是否有标准库来实现这一目标?
任何指针将不胜感激.
谢谢
我对Guava API相当新,并试图按MultiMap顺序或降序值对a的键进行排序.我是Map按照以下方式发起的:
ListMultimap<Date, Map<String, String>> listMultimap = MultimapBuilder.treeKeys().arrayListValues().build();
Run Code Online (Sandbox Code Playgroud)
这会按升序对键进行排序.例如:
List multi map iteration: key -->Fri Jan 01 00:00:00 PST 2016 values -->[{test2=testval2}, {test3=testval3}]
List multi map iteration: key -->Sun Jan 01 00:00:00 PST 2017 values -->[{test1=testval1}]
List multi map iteration: key -->Mon Jan 01 00:00:00 PST 2018 values -->[{test0=testval0}]
List multi map iteration: key -->Tue Jan 01 00:00:00 PST 2019 values -->[{test4=testval4}]
Run Code Online (Sandbox Code Playgroud)
我试图创建一个自定义日期Comparator有TreeMultiMap,但还没有一个数字的方式来做到这一点.这在语法上并不正确,只是试图证明这个想法.
static final Comparator<Date> DESC_ORDER = new Comparator<Date>() {
public …Run Code Online (Sandbox Code Playgroud) git commit我正在尝试使用 bash 脚本进行操作。我已经设置了一个 cron 作业来定期执行该脚本。如果我直接执行脚本,一切都会按预期进行。由于某种原因,当从 调用脚本时crontab,会git commit失败。这是脚本:
#!/bin/bash
cd /mnt/ebs2/sitemap
echo "Calling java application to generate sitemap"
java -jar SiteMap-1.0-jar-with-dependencies.jar -i sitemapconfig.xml -o /mnt/ebs2/sitemap/website_sitemaps -url ADSKContentURL
echo "sitemap generation complete.."
cd website_sitemaps
chmod 750 *
echo "Updated file permission, commiting to git..."
git commit -am 'automated weekly update'
git push -u
echo "git commit done..."
cd ..
Run Code Online (Sandbox Code Playgroud)
这是 crontab 的输出:
Calling java application to generate sitemap
sitemap generation complete..
Updated file permission, commiting to …Run Code Online (Sandbox Code Playgroud) 我最近开始使用 kafka 来阅读来自网络爬虫的文档。我注意到的是,当我处理几百万个文档时,消费者一遍又一遍地处理相同的消息。看起来数据由于某种原因没有提交。当我用几百条消息测试消费者时,情况并非如此。
我在 java 中使用 kafka 高级消费者客户端代码。我正在使用在线程数上运行的消费者组,该线程数等于分区数。所以每个线程都被指定为一个分区。这是用于轮询数据的代码片段。
while (true) {
try{
if(consumerDao.canPollTopic()){
ConsumerRecords records =
consumer.poll(this.config.getPropertyAsIneger(IPreProcessorConstant.KAFKA_POLL_COUNT));
for (ConsumerRecord record : records) {
if(record.value()!=null){
TextAnalysisRequest textAnalysisObj = record.value();
if(textAnalysisObj!=null){
PostProcessRequest req = new PostProcessRequest();
req.setRequest(this.getRequest(textAnalysisObj));
PreProcessorUtil.submitPostProcessRequest(req, config);
}
}
}
}else{
Thread.sleep(this.config.getPropertyAsIneger(IPreProcessorConstant.KAFKA_POLL_SLEEP));
}
}catch(Exception ex){
LOGGER.error("Error in Full Consumer group worker", ex);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我设置的kafka消费者配置参数。其余为默认值。
consumer.auto.commit=true
consumer.auto.commit.interval=1000
consumer.session.timeout=180000
consumer.poll.records=2147483647
consumer.request.timeout=181000
Run Code Online (Sandbox Code Playgroud)
这是完整的消费者配置:
metric.reporters =
metadata.max.age.ms = 300000
partition.assignment.strategy = [org.apache.kafka.clients.consumer.RangeAssignor]
reconnect.backoff.ms = 50
sasl.kerberos.ticket.renew.window.factor = 0.8
max.partition.fetch.bytes = 1048576
bootstrap.servers = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将kafka作为AWS SQS的替代品.动机主要是提高性能,其中kafka将消除限制,一次性提取10条消息,上限为256kb.这是我的用例的高级场景.我有一堆爬虫正在发送索引文件.有效载荷的大小平均约为1 MB.爬虫调用SOAP端点,后者又运行生产者代码以将消息提交给kafka队列.消费者应用程序接收消息并处理它们.对于我的测试框,我已经为主题配置了30个分区和2个复制.两个kafka实例正在运行1个zookeeper实例.卡夫卡版本是0.10.0.
对于我的测试,我在队列中发布了700万条消息.我创建了一个包含30个消费者线程的消费者组,每个分区一个.我最初的印象是,与我通过SQS获得的相比,这将大大加快处理能力.不幸的是,事实并非如此.就我而言,数据处理很复杂,平均需要1-2分钟才能完成.这导致了一系列的分区重新平衡,因为线程无法按时心跳.我可以在日志引用中看到一堆消息
组full_group的自动偏移提交失败:由于组已经重新平衡并将分区分配给另一个成员,因此无法完成提交.这意味着后续调用poll()的时间长于配置的session.timeout.ms,这通常意味着轮询循环花费了太多时间进行消息处理.您可以通过增加会话超时或通过max.poll.records减少poll()中返回的批量的最大大小来解决此问题.
这导致多次处理相同的消息.我尝试使用会话超时,max.poll.records和轮询时间来避免这种情况,但这会减慢整个处理时间.这是一些配置参数.
metadata.max.age.ms = 300000
max.partition.fetch.bytes = 1048576
bootstrap.servers = [kafkahost1:9092, kafkahost2:9092]
enable.auto.commit = true
max.poll.records = 10000
request.timeout.ms = 310000
heartbeat.interval.ms = 100000
auto.commit.interval.ms = 1000
receive.buffer.bytes = 65536
fetch.min.bytes = 1
send.buffer.bytes = 131072
value.deserializer = class com.autodesk.preprocessor.consumer.serializer.KryoObjectSerializer
group.id = full_group
retry.backoff.ms = 100
fetch.max.wait.ms = 500
connections.max.idle.ms = 540000
session.timeout.ms = 300000
key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
metrics.sample.window.ms = 30000
auto.offset.reset = latest
while (true) {
try{
ConsumerRecords records = consumer.poll(100);
for (ConsumerRecord record … 我正在尝试使用java反射调用带有变量参数的方法.这是承载方法的类:
public class TestClass {
public void setParam(N ... n){
System.out.println("Calling set param...");
}
Run Code Online (Sandbox Code Playgroud)
这是调用代码:
try {
Class<?> c = Class.forName("com.test.reflection.TestClass");
Method method = c.getMethod ("setParam", com.test.reflection.N[].class);
method.invoke(c, new com.test.reflection.N[]{});
Run Code Online (Sandbox Code Playgroud)
我在调用invoke的最后一行以"错误的参数数量"的形式得到IllegalArgumentException.不知道我做错了什么.
任何指针将不胜感激.
我只是想探索一个使用对象作为弹簧图中的值的用例.这是我的例子
<util:map id="someSourceMap" map-class="java.util.HashMap">
<entry key="source1" value="testLine"/>
<entry key="source2" value="testLine2"/>
</util:map>
<bean id="testLine1" class="com.test.ProductLineMetadata" scope="prototype">
<constructor-arg value="PRODUCT_LINE_1"></constructor-arg>
<constructor-arg value="TYPE_1"></constructor-arg>
</bean>
<bean id="testLine2" class="com.test.ProductLineMetadata"scope="prototype">
<constructor-arg value="PRODUCT_LINE_2"></constructor-arg>
<constructor-arg value="TYPE_2"></constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
我想要实现的是创建一个映射,其中值将是ProductLineMetadata对象的新实例,其中不同的参数通过构造函数参数设置.我不想为每个具有所需构造函数值的键创建单独的bean条目.有没有更好的方法通过以某种方式指定地图声明本身内的参数?
任何指针都将受到高度赞赏.
谢谢
java ×8
apache-kafka ×2
spring ×2
aws-sdk ×1
cron ×1
date ×1
date-format ×1
dictionary ×1
dom ×1
dom4j ×1
git ×1
git-commit ×1
guava ×1
maven ×1
multimap ×1
performance ×1
reflection ×1
shell ×1
solr ×1