这是我的枚举:
public enum FooBarType {
Foo,
Bar;
@javax.persistence.Converter
public static class Converter implements AttributeConverter<FooBarType, String> {
@Override
public String convertToDatabaseColumn(FooBarType t) {
return t.toString();
}
@Override
public FooBarType convertToEntityAttribute(String s) {
for (FooBarType value : FooBarType.values()) {
if (value.name().equalsIgnoreCase(s)) {
return value;
}
}
throw new IllegalArgumentException("Invalid value for enum: " + s);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的实体:
@Table
@IdClass(FooBar.PrimaryKey.class)
public class FooBar {
@Id
@Column(name = "id")
public String id;
@Id
@Column(name = "fooBarType")
@Convert(converter = FooBarType.Converter.class)
public FooBarType fooBarType; …Run Code Online (Sandbox Code Playgroud) 例如,我有这个 Maven 依赖项
<dependency>
<groupId>foo</groupId>
<artefactId>bar</artifactId>
<version>[1.0.0, 1.1.0)</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我试图实现的目标是包含所有补丁(1.0.x)版本,包括快照版本(以促进测试和集成),1.0.1-SNAPSHOT等等1.0.2。
但是,设置这样的版本范围[1.0.0, 1.1.0)将包括诸如1.1.0-alpha、1.1.0-beta和1.1.0-SNAPSHOT之类的版本,这是我不想要的。
有没有更好的方法,除了将版本指定为 之外[1.0.0, 1.1.0-alpha),这实际上只会用丑陋的版本号污染 POM。
(这不是关于尝试使用最新版本,而是关于如何优雅地排除alpha,beta并snapshot在独占版本范围内构建)
我正在运行在线摄影作品集,有时,页面上的1或2张图像无法加载.并刷新将显示无法加载图像.
场景:我点击链接,图像开始加载.但页面永远不会完成加载,因为其中一个图像无法加载.刷新后,浏览器将失败的图像加载为良好的图像.只有ctrl + F5才能清除缓存的失败图像.
计划的解决方案:我想检测10secs后没有完成加载的图像,并使用javascript/jquery动态重新加载它们.
我找到了一种方法来强制浏览器通过在src ="image.jpg?id = dummyNo"后面添加一个虚拟的唯一查询字符串来重新加载图像.但我不知道如何检测哪个图像没有完成加载,以便我可以重新加载它们.
是否有可能做到这一点?
在旁注,我想了解网站压缩和图像(加载时间)优化,哪里是我阅读的好地方?
java ×2
compression ×1
enums ×1
hibernate ×1
javascript ×1
jpa ×1
jquery ×1
maven ×1
spring-data ×1
version ×1