Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.springBootStarter.app;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- @SpringBootApplication
- public class CourseApiDataApplication
- {
- public static void main(String args[])
- {
- SpringApplication.run(CourseApiDataApplication.class,args);
- }
- }
- package pl.springBootStarter.app.topic;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- @Service
- public class TopicService
- {
- @Autowired
- private TopicRepository topicRepository;
- private List<Topic> topics = new ArrayList<>(Arrays.asList(
- new Topic("spring","spring framework", "spring framework dectription"),
- new Topic("sprin","spring framework", "spring framework dectription"),
- new Topic("spri","spring framework", "spring framework dectription")));
- public List<Topic> getAllTopics()
- {
- // return topics;
- List<Topic> t = new ArrayList<Topic>();
- topicRepository.findAll().forEach(t::add);
- return t;
- }
- public Topic getTopic (String id)
- {
- return topics.stream().filter( t -> t.getId().equals(id)).findFirst().get();
- }
- public void addTopic(Topic topic) {
- topicRepository.save(topic);
- }
- public void updateTopic(Topic topic, String id)
- {
- topics.set(topics.indexOf(topics.stream().filter(t-> t.getId().equals(id)).findFirst().get()), topic);
- }
- public void deleteTopic(String id)
- {
- topics.remove(topics.stream().filter(t -> t.getId().equals(id)).findFirst().get());
- }
- }
- package pl.springBootStarter.app.topic;
- import org.springframework.data.repository.CrudRepository;
- public interface TopicRepository extends CrudRepository<Topic,String>
- {
- }
- Error starting ApplicationContext. To display the conditions report re- run your application with 'debug' enabled.
- 2019-05-01 10:33:52.206 ERROR 6972 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
- ***************************
- APPLICATION FAILED TO START
- ***************************
- Description:
- Field topicRepository in pl.springBootStarter.app.topic.TopicService required a bean of type 'pl.springBootStarter.app.topic.TopicRepository' that could not be found.
- The injection point has the following annotations:
- - @org.springframework.beans.factory.annotation.Autowired(required=true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement