I am new to Spring programming and currently struggling with Spring 3.1’s Java Based Configuraion” I have created following Configuration class
@Configuration
@ImportResource("classpath:/resources/jdbc.properties")
public class AppConfig {
@Autowired
Environment env;
private @Value("${jdbc.url}")
String url;
private @Value("${jdbc.username}")
String username;
private @Value("${jdbc.password}")
String password;
@Bean
public DataSource dataSource() {
System.out.println("Creating data Source.");
return new DriverManagerDataSource(url, username, password);
}
@Bean
public SessionFactory sessionFactory () throws Exception {
return new AnnotationSessionFactoryBuilder().setDataSource(dataSource()).setPackagesToScan("com.argusoft.loginmodule.domain").buildSessionFactory();
}
}
now when I try to run the project I get following error.
OUTPUT
SEVERE: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: javax.servlet.ServletException:
java.lang.NoClassDefFoundError:
org/springframework/core/env/EnvironmentCapable
stuck into it, Cant solve it….. I am following Spring Source Blog.
please also suggest some good tutorial in which Spring’s latest Java based configuration is explained by easy to understand examples…
Thanks in advance,
From the perspective of the exception:
This question is equals to the question: Spring class EnvironmentCapable
So the correct answer might be:
given by user810430 here: original answer.