我正在寻找configurationOnProperty可以指定考虑多个值的用法,如下所示
例如: @ConditionalOnProperty(value = "test.configname", havingValue = "value1" or "value2")
要么
我想知道是否可以指定confiugrationOnProperty条件havingValue != "value3"
例如: @ConditionalOnProperty(value = "test.configname", havingValue != "value3")
请让我知道是否有一种方法可以实现上述任何一项spring boot配置。
我正在尝试编写正则表达式Java来评估两个用()分隔的字符串,
Example: (test1,test2)
Run Code Online (Sandbox Code Playgroud)
我写了下面的代码
public static void main(String[] a){
String pattern = "\\([a-zA-Z0-9]+,[a-zA-Z0-9]+.\\)";
String test = "(test1,test2)";
System.out.println(test.matches(pattern));
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作,并true在下面的情况下打印
String test = "(test1,test2)";
String test = "(t,test2)";
Run Code Online (Sandbox Code Playgroud)
但是false当我发送到下面时它正在打印
String test = "(test1,t)";
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我之前和之后都使用相同的表达方式,
它返回true了(t,test2),但不(test1,t)
请告诉我这个正则表达式中缺少的内容.我需要它来计算并返回true的(test1,t)
当写入文件Mongodb使用Morphia,这样的结构将被写入没有任何问题,并没有需要的@Embedded注释:
@Entity
public class Blog {
@Id
private String id;
private List<Comment> comments;
}
Run Code Online (Sandbox Code Playgroud)
该comments字段被愉快地存储为嵌套Comment元素数组(Comment是一个没有注释的普通 POJO)。
但是,Morphia文档建议我应该使用它:
@Entity
public class Blog {
@Id
private String id;
@Embedded
private List<Comment> comments;
}
Run Code Online (Sandbox Code Playgroud)
但是在我的测试中,使用@Embedded注释似乎并没有比简单地编写没有注释的结构做任何额外的事情。
那么@Embedded注解实际上是做什么的呢?除了简单地写入数据之外,它是否会影响查询、索引或其他一些存储功能的能力?