My web application runs fine on JDK 1.7 but crashes on 1.8 with the following exception (during application server startup with Jetty 8). I am using Spring version: 3.2.5.RELEASE.
org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet
I assume that problem occurs because of spring and "asm.jar" library on which it depends.
How do I resolve this?
我想创建一个枚举并在其中声明几个常量以供内部使用...
public enum SearchType {
static final String TEXT = "text";
static final String BOOLEAN = "boolean";
STARTS_WITH(TEXT),
ENDS_WITH(TEXT),
CONTAINS(BOOLEAN),
WILDCARD(TEXT),
REGEXP(TEXT),
RANGE(TEXT)
private String searchType;
private SearchType(String type) {
searchType = type;
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,不能这样做.到目前为止我提出的最佳解决方案是声明一个嵌套的接口来存储常量......
public enum SearchType {
STARTS_WITH(Categories.TEXT),
ENDS_WITH(Categories.TEXT),
CONTAINS(Categories.BOOLEAN),
WILDCARD(Categories.TEXT),
REGEXP(Categories.TEXT),
RANGE(Categories.TEXT)
interface Categories{
static final String TEXT = "text";
static final String BOOLEAN = "boolean";
}
private String searchType;
private SearchType(String type) {
searchType = type;
}
}
Run Code Online (Sandbox Code Playgroud)
所以我想知道是否有更好的方法吗?
我try-with-resources在Scala中有这个版本。我想知道是否可以使用Shapeless和HList制作通用版本?
import scala.util.{Failure, Success, Try}
class Loan1[A <: AutoCloseable](resource: A) {
def to[B](block: A => B): B = {
Try(block(resource)) match {
case Success(result) =>
resource.close()
result
case Failure(e) =>
resource.close()
throw e
}
}
}
class Loan2[A <: AutoCloseable, B <: AutoCloseable](r1: A, r2: B){
def to[R](block: (A,B) => R): R = {
Try(block(r1,r2)) match {
case Success(result) =>
r1.close(); r2.close()
result
case Failure(e) =>
r1.close(); r2.close()
throw e
}
}
}
object Loan {
def apply[A …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring-Data-Elastic-Search进行搜索/缓存.我需要执行一个使用子(TermCache)和父(ConceptCache)属性的查询并返回子对象的实例(这意味着我不能使用嵌套对象).
我有以下结构:
@Document(indexName = "termweb" , type = "term")
public class TermCache {
@Id
private String id;
private String name;
private LanguageDTO language;
private String status;
private String definition;
@Field(type = FieldType.String, store = true)
@Parent(type = "concept")
private Long conceptId;
private String displayId;
private Map<Long, String> fields = new HashMap<>();
//todo think about storing it as a collection of nested objects
}
@Document( indexName = "termweb" , type = "concept")
public class ConceptCache implements ConceptDTO{
@Id
private String id; …Run Code Online (Sandbox Code Playgroud) 我有几个重载方法的服务,例如:
MyService.execute(Long id);
MyService.execute(Collection collection);
Run Code Online (Sandbox Code Playgroud)
我需要通过AOP拦截'MyService.execute(Long id)'的执行,如:
@Aspect
@Component
public class AopInterseptor{
@After("execution(* my.Service.MyService.execute(..))")
public void intercept(JoinPoint joinPoint) throws Exception {
// Do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
有可能这样做吗?
我有一个对元素进行分组的源和一个发出批处理请求的接收器,我使用KillSwitch能够在任意时间点关闭图形。switch.shutdown()调用时源输出丢失的最新不完整批次记录的问题
val source = Source.tick(10.millis, 10.millis, "tick").grouped(500)
val (switch, _) = source.viaMat(KillSwitches.single)(Keep.right)
.toMat(sink)(Keep.both).run()
Thread.sleep(3000) // wait some arbitrary time
switch.shutdown()
Run Code Online (Sandbox Code Playgroud)
关机时有办法“清除”未完成的批次吗?
我想映射一对String的选项,如下所示
val pair: (Option[String], Option[String]) = (Some("a"), None)
val mapped: (String, String) = pair map {case (a:Option[String],b:Option[String]) => (a.getOrElse(""),b.getOrElse(""))}
Run Code Online (Sandbox Code Playgroud)
但输出签名与我的预期不同
(Option[String],(String,String))
Run Code Online (Sandbox Code Playgroud)
看来我在这里遗漏了一些东西......也许scalaz或shapeless允许映射元组的这种功能?
java ×3
scala ×3
spring ×2
akka-stream ×1
aspectj ×1
constants ×1
enums ×1
hlist ×1
java-8 ×1
shapeless ×1
spring-aop ×1
spring-data ×1