要求:发现不兼容的类型中的注释默认枚举 [英] incompatible types found: required: default enums in annotations
问题描述
[javac的] C:\\ WS \\伽利略\\测试\\ Cacheable.java:13:不兼容的类型
[javac的]研究发现:com.io.CacheType
[javac的]要求:com.io.CacheType
[javac的]公共CacheType ID()默认CacheType.COMMON;
我真的不明白这一点。
我有一个项目,我自定义构建缓存的拦截器弹簧。它只是一看就是被高速缓存名称指向的Ehcache和使用AOP的自动代理加载CacheableAspect(这是我的缓存截击)。现在,当我在注释中使用默认值,ANT给我的编译器错误的下面。我试图更新到最新的JDK(我是1.6,现在16),在ant脚本,但没有成功设置源/目标水平。当我删除默认值,并强制所有地区指定的值,它编译于蚂蚁罚款。
它总是在Eclipse工作,我有单元测试,与previous默认值完美运行。
怎么办?我试图建立一个项目(无弹簧),简单地用蚂蚁呼应的配置,并在蚂蚁精编(和月食)。
这告诉我,也许它可能是弹簧自动代理不知何故?但为什么会编译器不给我生成的类型名称? GRRRR。有什么想法?
进口java.lang.annotation.ElementType;
进口java.lang.annotation.Retention;
进口java.lang.annotation.RetentionPolicy;
进口java.lang.annotation.Target;进口com.io.CacheType;@Retention(RetentionPolicy.RUNTIME)
@Target({} ElementType.METHOD)
公共@interface可缓存{
公共CacheType值()默认Cachetype.COMMON;
}公共枚举CacheType { COMMON(常用),
持久(老大难; 私人字符串缓存; CacheType(字符串缓存){
this.cache =高速缓存;
} 公共字符串缓存(){
返回this.cache;
}
}
不过美元的JDK 6u25 p $ psent,但添加包默认值的伎俩:
CacheType值()默认com.io.CacheType.COMMON;
[javac] C:\ws\galileo\test\Cacheable.java:13: incompatible types
[javac] found : com.io.CacheType
[javac] required: com.io.CacheType
[javac] public CacheType id() default CacheType.COMMON;
I really don't get this one. I have a project where I'm custom building a caching interceptor for Spring. It simply is a look by cache name to point to EhCache and uses aop-autoproxy to load the CacheableAspect (which is my caching intercepter). Now when I use the default value in the annotation, ANT gives me the compiler error below. I tried updating to the latest JDK (i'm on 1.6 16 now) and setting source/target levels in the ant script but no success. When I remove the default value and force all areas to specify a value, it compiles in ant fine.
It always worked in Eclipse, I had unit tests that ran perfectly with the previous default value.
What gives? I tried building a project (no spring) that simply echoed the configuration with ant and it compiled in ant fine (and in eclipse).
that tells me MAYBE it might be the spring auto-proxying somehow? but then why would the compiler not give me the generated type name? GRRRR. Any thoughts?
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.io.CacheType;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Cacheable {
public CacheType value() default Cachetype.COMMON;
}
public enum CacheType {
COMMON("common"),
PERSISTENT("persistent";
private String cache;
CacheType(String cache) {
this.cache = cache;
}
public String cache() {
return this.cache;
}
}
Still present in JDK 6u25, but adding package to default value does the trick:
CacheType value() default com.io.CacheType.COMMON;
这篇关于要求:发现不兼容的类型中的注释默认枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!