Advertisement
Guest User

Untitled

a guest
Aug 11th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.04 KB | None | 0 0
  1. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mkyong.config.SecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.mkyong.config.SecurityConfig.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class com.mkyong.config.AppConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.jdbc.datasource.DriverManagerDataSource com.mkyong.config.AppConfig.dataSource()] threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${mysql.jdbc.driver}]
  2. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
  6. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
  7. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  10. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
  11. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
  12. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
  13. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
  14. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  15. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  16. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4840)
  17. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
  18. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
  19. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
  20. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
  21. at java.util.concurrent.FutureTask.run(Unknown Source)
  22. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  23. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  24. at java.lang.Thread.run(Unknown Source)
  25. Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mkyong.config.SecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.mkyong.config.SecurityConfig.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class com.mkyong.config.AppConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.jdbc.datasource.DriverManagerDataSource com.mkyong.config.AppConfig.dataSource()] threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${mysql.jdbc.driver}]
  26. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:604)
  27. at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
  28. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
  29. ... 22 more
  30. Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mkyong.config.SecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.mkyong.config.SecurityConfig.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class com.mkyong.config.AppConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.jdbc.datasource.DriverManagerDataSource com.mkyong.config.AppConfig.dataSource()] threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${mysql.jdbc.driver}]
  31. at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)
  32. at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1318)
  33. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:782)
  34. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
  35. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
  36. ... 24 more
  37. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mkyong.config.SecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.mkyong.config.SecurityConfig.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class com.mkyong.config.AppConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.jdbc.datasource.DriverManagerDataSource com.mkyong.config.AppConfig.dataSource()] threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${mysql.jdbc.driver}]
  38. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
  39.  
  40. mysql.jdbc.driver=com.mysql.jdbc.Driver
  41. mysql.url=jdbc:mysql://localhost:3306/test
  42. mysql.username=root
  43. mysql.password=root
  44.  
  45. @EnableWebMvc
  46. @Configuration
  47. @ComponentScan({ "com.mkyong.web.*" })
  48. @Import({ SecurityConfig.class })
  49. @PropertySource({"classpath:database.properties"})
  50. public class AppConfig {
  51.  
  52. @Value("${mysql.jdbc.driver}")
  53. private String driverClass;
  54.  
  55. @Value("${mysql.url}")
  56. private String url;
  57.  
  58. @Value("${mysql.username}")
  59. private String username;
  60.  
  61. @Value("${mysql.password}")
  62. private String password;
  63.  
  64.  
  65. @Bean(name = "dataSource")
  66. public DriverManagerDataSource dataSource() {
  67. DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
  68. /*driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
  69. driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/test");
  70. driverManagerDataSource.setUsername("root");
  71. driverManagerDataSource.setPassword("root");*/
  72.  
  73. driverManagerDataSource.setDriverClassName(driverClass);
  74. driverManagerDataSource.setUrl(url);
  75. driverManagerDataSource.setUsername(username);
  76. driverManagerDataSource.setPassword(password);
  77.  
  78. return driverManagerDataSource;
  79. }
  80.  
  81. @Bean
  82. public InternalResourceViewResolver viewResolver() {
  83. InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
  84. viewResolver.setViewClass(JstlView.class);
  85. viewResolver.setPrefix("/WEB-INF/pages/");
  86. viewResolver.setSuffix(".jsp");
  87. return viewResolver;
  88. }
  89. }
  90.  
  91. @Bean
  92. public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
  93. return new PropertySourcesPlaceholderConfigurer();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement