Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //starter
  2. @SpringBootApplication
  3. @EnableAsync
  4. @EnableWebSecurity
  5. public class Starter {
  6. public static void main(String[] args) {
  7. SpringApplication.run(Starter.class);
  8. }
  9. }
  10.  
  11. //CONFIG
  12. @Configuration
  13. public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
  14. @Override
  15. protected void configure(HttpSecurity http) throws Exception {
  16. http.cors();
  17. }
  18.  
  19. }
  20. // CONFIG
  21. @Configuration
  22. public class WebMvcConfig implements WebMvcConfigurer {
  23. @Override
  24. public void addCorsMappings(CorsRegistry registry) {
  25. registry.addMapping("/**").allowedOrigins("").allowedMethods("GET,POST");
  26. }
  27.  
  28. @Bean
  29. public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> webServerFactoryCustomizer(){
  30. return container->{
  31.  
  32. container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/index.html"));
  33. };
  34. }
  35. }
  36.  
  37. //Controller
  38. @GetMapping("/getAllMessages")
  39. public List<Message> getAllMessages() throws Exception{
  40. return messageService.getAllMessages();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement