我有一个 Spring Boot 应用程序,必须从 yaml 文件读取属性。
代码:
@Component
@PropertySource("classpath:application.yml")
public class ResourceProvider {
@Autowired
private Environment env;
public String getValue(String key) {
return env.getProperty("app.max.size");
}
}
Run Code Online (Sandbox Code Playgroud)
yaml 文件
app:
max:
size: 10
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,它不起作用。我得到的值为app.max.size空。因为size我得到的值为 10。
当我使用 application.properties 时。我能够得到想要的结果。我做错了什么吗?
应用程序属性
app.max.size=10
Run Code Online (Sandbox Code Playgroud) 我正在使用snakeyaml在YAML文件中打印我的对象.有些字段可能为null.当它们在文件中打印为空时,如何防止这些字段?
我无法从System.Data.Linq Visual Studio 2013更新2中的添加引用添加System.Data.Linq引用.此引用未显示,它表示已添加所有可用引用.但是当我导入System.Data.Linq和System.Data.Linq.Mapping时,它会显示我是否缺少引用或程序集.
我想删除会话变量或在JSTL中将其设置为null。请帮我。如果我尝试使用
<c:set var="varialbleName" value=null scope="session" />
Run Code Online (Sandbox Code Playgroud)
但这给了我以下服务器错误。
Server Error
Caused by:
org.apache.jasper.JasperException: /WEB-INF/jsps/forum.jsp (line: 78, column: 71) quote symbol expected
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:276)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:92)
at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:223)
at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:163)
at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:154)
at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1231)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1453)
at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1666)
at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:996)
at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1271)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1453)
at org.apache.jasper.compiler.Parser.parse(Parser.java:139)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
Run Code Online (Sandbox Code Playgroud) 我有一个 Cassandra 2.1 集群,我们通过 Java 使用 TTL 插入数据,因为保存数据的要求是 30 天。但这会导致问题,因为带有逻辑删除的旧数据的文件保留在磁盘上。这会导致磁盘空间被不需要的数据占用。修复需要花费大量时间来清除这些数据(单个节点上最多需要 3 天)是否有更好的方法来删除数据?
我在 datastax 上遇到过这个
Cassandra 允许您为整个表设置 default_time_to_live 属性。如上所述处理标有常规 TTL 的列和行;但是当记录超过表级 TTL 时,Cassandra 会立即删除它,而不进行逻辑删除或压缩。https://docs.datastax.com/en/cassandra/3.0/cassandra/dml/dmlAboutDeletes.html?hl=tombstone
如果我在表级别设置TTL而不是每次插入时都设置,删除数据的效率会更高吗?另外,文档适用于 Cassandra 3,所以我是否必须升级到新版本才能获得任何好处?