Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package com.whattodo;
  2.  
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.ComponentScan;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.jdbc.datasource.DriverManagerDataSource;
  7. import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  8. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  9. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  10.  
  11. import javax.sql.DataSource;
  12.  
  13. /**
  14. * Created by knalum on 8/22/16.
  15. */
  16.  
  17. @Configuration
  18. @ComponentScan(basePackages = "com.whattodo")
  19. @EnableWebMvc
  20.  
  21. public class MvcConfiguration extends WebMvcConfigurerAdapter{
  22. @Bean
  23. public DataSource getDataSource(){
  24. DriverManagerDataSource dataSource = new DriverManagerDataSource();
  25. dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  26. dataSource.setUsername("jdbc:mysql://localhost:3306/item");
  27. dataSource.setUsername("client");
  28. dataSource.setUsername("client");
  29.  
  30. return dataSource;
  31. }
  32.  
  33. @Bean
  34. public ItemDaoInterface getItemDao(){
  35. return new ItemDao(getDataSource());
  36. }
  37.  
  38. @Override
  39. public void addResourceHandlers(ResourceHandlerRegistry registry) {
  40. registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement