Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //starter
- @SpringBootApplication
- @EnableAsync
- @EnableWebSecurity
- public class Starter {
- public static void main(String[] args) {
- SpringApplication.run(Starter.class);
- }
- }
- //CONFIG
- @Configuration
- public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.cors();
- }
- }
- // CONFIG
- @Configuration
- public class WebMvcConfig implements WebMvcConfigurer {
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/**").allowedOrigins("").allowedMethods("GET,POST");
- }
- @Bean
- public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> webServerFactoryCustomizer(){
- return container->{
- container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/index.html"));
- };
- }
- }
- //Controller
- @GetMapping("/getAllMessages")
- public List<Message> getAllMessages() throws Exception{
- return messageService.getAllMessages();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement