我是Kotlin的新手,所以也许我误解了这个课程:
@Component
open class SimpleStoreBuilder {
open fun <T : Entity> build(tableName: String): Store<T>? {
return Store()
}
inner class Store<T:Entity>
}
抛出此运行时异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storeBuilder' defined in file [xxx\StoreBuilder.class]: Initialization of bean failed; nested exception is java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected '<' or ';' but got .
Remaining input: .Store<TT;>;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at cz.webexo.ApplicationKt.main(Application.kt:28) [main/:na]
Caused by: java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected '<' or ';' but got .
Remaining input: .Store<TT;>;
at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parsePackageNameAndSimpleClassTypeSignature(SignatureParser.java:348) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignature(SignatureParser.java:310) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:289) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:283) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:485) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseReturnType(SignatureParser.java:627) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseMethodTypeSignature(SignatureParser.java:577) ~[na:1.8.0_101]
at sun.reflect.generics.parser.SignatureParser.parseMethodSig(SignatureParser.java:171) ~[na:1.8.0_101]
at sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:55) ~[na:1.8.0_101]
at sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:43) ~[na:1.8.0_101]
at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:74) ~[na:1.8.0_101]
at sun.reflect.generics.repository.GenericDeclRepository.<init>(GenericDeclRepository.java:49) ~[na:1.8.0_101]
at sun.reflect.generics.repository.ConstructorRepository.<init>(ConstructorRepository.java:51) ~[na:1.8.0_101]
at sun.reflect.generics.repository.MethodRepository.<init>(MethodRepository.java:46) ~[na:1.8.0_101]
at sun.reflect.generics.repository.MethodRepository.make(MethodRepository.java:59) ~[na:1.8.0_101]
at java.lang.reflect.Method.getGenericInfo(Method.java:102) ~[na:1.8.0_101]
at java.lang.reflect.Method.getGenericInfo(Method.java:61) ~[na:1.8.0_101]
at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:283) ~[na:1.8.0_101]
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:283) ~[na:1.8.0_101]
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387) ~[na:1.8.0_101]
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116) ~[na:1.8.0_101]
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72) ~[na:1.8.0_101]
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56) ~[na:1.8.0_101]
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1205) ~[na:1.8.0_101]
at java.beans.Introspector.getBeanInfo(Introspector.java:426) ~[na:1.8.0_101]
at java.beans.Introspector.getBeanInfo(Introspector.java:262) ~[na:1.8.0_101]
at java.beans.Introspector.getBeanInfo(Introspector.java:204) ~[na:1.8.0_101]
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:278) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:189) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:173) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:248) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1373) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
... 15 common frames omitted
这是一个错误还是我做错了什么?
由于
答案 0 :(得分:2)
我很抱歉这样说,但这是一个众所周知的错误:https://youtrack.jetbrains.com/issue/KT-10397
我认为暂时最好根据通用类创建一个具体类,并将其用作返回类型。