spring 404 not found

spring 404 not found
0

witam, chciałem pobierać resta z api/news/getNews ale ciągle dostaję 404 not found. Od godziny próbuję znaleźć błąd i nie mam pojęcia co może być przyczyną Próbowałem wyświetlać cokolwiek, jakiś komunikat w konsoli ale wg nie wywołuje tej funkcji findAll:/ Wstawiam kod controllera i klasy rozruchowej

Kopiuj
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@EnableAutoConfiguration
@ComponentScan
@Configuration
public class Angular2Application {

	public static void main(String[] args) {
		SpringApplication.run(Angular2Application.class, args);
	}
}

Kopiuj
package rest;

import java.util.List;

import model.News;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import service.CommentService;
import service.NewsService;

@RestController
@RequestMapping("/api/news")
public class AppRestController {
	private final CommentService commentService;
	private final NewsService newsService;
	
	@Autowired
	public AppRestController(CommentService cs, NewsService ns){
		this.commentService = cs;
		this.newsService = ns;
	}
	
	@RequestMapping(method = RequestMethod.GET, value="/getNews")
	public @ResponseBody List<News> findAll(){
		return newsService.getObj();
	}

	
}

SW
  • Rejestracja:prawie 13 lat
  • Ostatnio:ponad 4 lata
  • Postów:426
0

Konfiguracja i kontroler są całkowicie w innych pakietach, @ComponentScan nie ogarnie przez to @RestController i nie stworzy beana

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.