我正在学习groovy,我正在尝试使用所有字段的默认值动态初始化我的类.所以我正在进行的是,我正在获取所有属性的列表并获取该对象的类型并创建该类型的对象,但我在执行时遇到错误newInstance:
Exception in thread "main" org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method <init>() to invoke from this list:
public java.lang.Boolean#<init>(boolean)
public java.lang.Boolean#<init>(java.lang.String)
at groovy.lang.MetaClassImpl.chooseMethodInternal(MetaClassImpl.java:3160)
at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:3097)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1707)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1526)
Run Code Online (Sandbox Code Playgroud)
下面是代码
public static void init() {
Position position1 = new Position();
JXPathContext context = JXPathContext.newContext(position1)
context.createPathAndSetValue('id', '2')
position1.properties.each { Map.Entry entry ->
String propertyName = entry.key;
if (!propertyName.equalsIgnoreCase('class')) {
Class clazz = position1.class.getDeclaredField(propertyName)?.type
println "$clazz"
Object ob = clazz.newInstance()
}
}
Identifier sourceSystemPositionId = new Identifier()
context.setValue('sourceSystemPositionId/content', 'default-content')
context.setValue('sourceSystemPositionId/domain', …Run Code Online (Sandbox Code Playgroud) 您好我如何检索目录中的所有文档的URI.我创建了下面的xquery来实现它,但这没有帮助.
for $i in xdmp:directory("/Test/performance/results/","infinity")
let $k := document-uri(fn:doc($i))
return <li>{$k}</li>
Run Code Online (Sandbox Code Playgroud) 有没有办法在使用声明性事务管理捕获异常后回滚事务。我有这段代码。
@Component
@Transactional(rollbackFor = EvictionException.class)
Public class Eviction{
@Autowired
private Alerter alerter;
@Scheduled(cron = "${evictor.cron.expression}")
public void evictObjectFromDatabase(){
try{
....
DO SOME DELETION QUERIES
}catch(Exception ex){
alerter.produceAlert("Failed to delete entries from database");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果删除时产生异常,我需要发出警报,由另一个团队监视 Swing UI。我还需要回滚事务,但使用 rollBackFor = Exception.class 不起作用。
我使用typesafe配置来读取一些初始配置.
有没有办法检查类型配置中是否存在密钥的一部分.例如,我有以下配置:
foo {
bar {
x = 42
y = 92
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我想检查我的conf包含foo.bar我不在乎任何配置x或y两者都存在一方的存在.
我只想检查配置中是否存在bar的配置.可能吗?
我正在尝试创建一个可用于监控 Spring Boot 应用程序的平台。我选择了infulxdb作为数据可视化的TSDB和grafana的选择。
我用 spring boot 创建了一个解决方案,它能够在称为堆的测量中推送 influxDB 中的数据。
我也在 Grafana 中配置了一个数据源
接下来我创建了一个仪表板并添加了一个带有如下指标的图表面板
这里的问题是每次我必须看到那个图表时,我必须点击缩小旁边的右箭头,图表应该自动移动,并以最新的时间为焦点。它保持不变,有人可以建议我在这里缺少什么吗?
我在测试用例中使用 spock,并按如下方式存根一个类,inventryDAO 有一个 getUser 方法,它接受 PersistableKey 类型的参数。
在主代码中,参数创建如下
PersistableKey userKey = new PersistableKey(1)
userKey.setRepresentedObjectClass(User.class);
Run Code Online (Sandbox Code Playgroud)
在我的规范中,如果我按如下方式编写存根和参数,则效果很好
User collUser = new User(1);
InventoryDAO inventoryDAO = Stub()
PersistableKey userKey = new PersistableKey(1)
userKey.setRepresentedObjectClass(User.class);
inventoryDAO.getUser(userKey) >> collUser
Run Code Online (Sandbox Code Playgroud)
但我真正想做的是能够在不设置 setRepresentedObjectClass 的情况下传递参数,如下所示
User collUser = new User(1);
InventoryDAO inventoryDAO = Stub()
PersistableKey userKey = new PersistableKey(1)
inventoryDAO.getUser(userKey) >> collUser
Run Code Online (Sandbox Code Playgroud)
是否可以根据部分值匹配参数?
需要一些关于编年史地图如何工作的信息,是否像它在内存中保留一些键值对,当它溢出一个特定的阈值时,它会如何存储值,然后它会将数据溢出到磁盘,或者它取决于内存大小,如果地图的大小增长到阈值以上然后将数据溢出到磁盘,如果是这样,那么如何配置它,或者还有其他策略吗?
我正在学习春季批,我有读者,映射器和作家的基本思想.现在我的当前要求是从文件中读取每一行,压缩数据并在基于gigaspace的内存网格中写入.
我知道行映射器是iteam reader的必需属性.我没有使用创建映射器,我需要做的就是读取该行并将其发送给编写器以在网格中写入.那么我怎样才能跳过行映射器或者我如何阅读普通线.目前我已经做过类似的事情,这似乎不是理想的解决方案.
public class ShrFileMapper implements FieldSetMapper<SpaceDocument> {
@Override
public SpaceDocument mapFieldSet(FieldSet fieldSet) throws BindException {
String positionId = fieldSet.readString(0);
StringBuffer line = new StringBuffer();
for (String fieldValue : fieldSet.getValues()) {
line.append("\t").append(fieldSet);
}
// logic for compression
SpaceDocument spaceDocument = new SpaceDocument("shr.doc");
spaceDocument.setProperty("id", positionId);
spaceDocument.setProperty("payload", compressedString);
return spaceDocument;
}
}
Run Code Online (Sandbox Code Playgroud) java ×5
spring ×2
batch-file ×1
chronicle ×1
config ×1
grafana ×1
groovy ×1
influxdb ×1
marklogic ×1
mocking ×1
spock ×1
spring-batch ×1
spring-boot ×1
transactions ×1
typesafe ×1
xquery ×1