Hello,
I am just trying the sample code to get the feel of JavaConfig. I am facing the exception while loading the JavaConfigApplicationContext. Following the stack trace for reference.
The code is as followsCode:13-Jul-2009 00:11:47 org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.config.java.context.JavaConfigApplicationContext@3ef810: display name [org.springframework.config.java.context.JavaConfigApplicationContext@3ef810]; startup date [Mon Jul 13 00:11:47 BST 2009]; root of context hierarchy 13-Jul-2009 00:11:47 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.config.java.context.JavaConfigApplicationContext@3ef810]: org.springframework.beans.factory.support.DefaultListableBeanFactory@3a5794 Exception in thread "main" java.lang.annotation.AnnotationFormatError: Invalid default: public abstract org.springframework.beans.factory.annotation.Autowire org.springframework.config.java.annotation.Configuration.defaultAutowire() at java.lang.reflect.Method.getDefaultValue(Method.java:728) at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:99) at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:66) at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:202) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69) at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072) at java.lang.Class.getAnnotation(Class.java:3029) at org.springframework.config.java.internal.util.AnnotationExtractionUtils.extractClassAnnotation(AnnotationExtractionUtils.java:41) at org.springframework.config.java.internal.model.ConfigurationClass.<clinit>(ConfigurationClass.java:65) at org.springframework.config.java.internal.parsing.asm.AsmConfigurationParser.parse(AsmConfigurationParser.java:72) at org.springframework.config.java.internal.factory.support.AsmJavaConfigBeanDefinitionReader.loadBeanDefinitions(AsmJavaConfigBeanDefinitionReader.java:70) at org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.parseAnyConfigurationClasses(InternalConfigurationPostProcessor.java:128) at org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.postProcessBeanFactory(InternalConfigurationPostProcessor.java:76) at org.springframework.config.java.context.JavaConfigApplicationContext.invokeBeanFactoryPostProcessors(JavaConfigApplicationContext.java:121) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:359) at org.springframework.config.java.context.JavaConfigApplicationContext.<init>(JavaConfigApplicationContext.java:80) at com.my.Test.main(Test.java:8)
Am I missing something? Any help appreciated.Code:package com.my; import org.springframework.config.java.context.JavaConfigApplicationContext; public class Test { public static void main(String args[]){ JavaConfigApplicationContext ctx = new JavaConfigApplicationContext(AppConf.class); Employee emp = ctx.getBean(Employee.class); } } package com.my; import org.springframework.config.java.annotation.Bean; import org.springframework.config.java.annotation.Configuration; @Configuration public class AppConf { @Bean public Employee employee(){ return new Employee(); } } package com.my; public class Employee { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
Cheers,
Rahul


