Skip to content

Commit c324c72

Browse files
author
a_total_another_bla
committed
frontend template
1 parent 60061d1 commit c324c72

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed
Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.woehlke.learn.learnneo4j;
22

3-
import org.springframework.beans.factory.annotation.Autowired;
4-
import org.springframework.boot.CommandLineRunner;
3+
54
import org.springframework.boot.SpringApplication;
6-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
75
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
/*
7+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.boot.CommandLineRunner;
810
import org.springframework.context.annotation.ComponentScan;
911
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
1012
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
@@ -13,41 +15,22 @@
1315
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
1416
import org.woehlke.learn.learnneo4j.model.Category;
1517
import org.woehlke.learn.learnneo4j.model.category.CategoryRepository;
16-
17-
18+
*/
19+
/*
1820
@ComponentScan({"org.woehlke.learn.learnneo4j.model","org.woehlke.learn.learnneo4j.components"})
1921
@EnableJpaRepositories({"org.woehlke.learn.learnneo4j.components.db"})
2022
@EnableNeo4jRepositories({"org.woehlke.learn.learnneo4j.model","org.woehlke.learn.learnneo4j.components"})
2123
@EnableAutoConfiguration
2224
@EnableWebMvc
2325
@EnableTransactionManagement
2426
@EnableSpringDataWebSupport
27+
*/
2528
@SpringBootApplication
26-
public class LearnNeo4jApplication implements CommandLineRunner {
29+
public class LearnNeo4jApplication {
2730

28-
@Autowired
29-
private CategoryRepository categoryRepository;
3031

3132
public static void main(String[] args) {
3233
SpringApplication.run(LearnNeo4jApplication.class, args);
3334
}
3435

35-
@Override
36-
public void run(String... args) throws Exception {
37-
this.categoryRepository.deleteAll();
38-
this.categoryRepository.save(new Category("www"));
39-
this.categoryRepository.save(new Category("qt4"));
40-
this.categoryRepository.save(new Category("qt5"));
41-
// fetch all Categories
42-
System.out.println("Categories found with findAll():");
43-
System.out.println("--------------------------------");
44-
for (Category category : this.categoryRepository.findAll()) {
45-
System.out.println(category);
46-
}
47-
System.out.println();
48-
// fetch an individual Category
49-
System.out.println("Category found with findByCategory('www'):");
50-
System.out.println("--------------------------------");
51-
System.out.println(this.categoryRepository.findByName("www"));
52-
}
5336
}

src/main/java/org/woehlke/learn/learnneo4j/components/StartupListener.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,44 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Autowired;
56
import org.springframework.context.ApplicationListener;
67
import org.springframework.context.event.ContextRefreshedEvent;
78
import org.springframework.stereotype.Component;
9+
import org.woehlke.learn.learnneo4j.model.Category;
10+
import org.woehlke.learn.learnneo4j.model.category.CategoryRepository;
811

912
@Component
1013
public class StartupListener implements ApplicationListener<ContextRefreshedEvent> {
1114

1215
private static Logger log = LoggerFactory.getLogger(StartupListener.class.getName());
1316

17+
private final CategoryRepository categoryRepository;
18+
19+
@Autowired
20+
public StartupListener(CategoryRepository categoryRepository) {
21+
this.categoryRepository = categoryRepository;
22+
}
23+
1424
@Override
1525
public void onApplicationEvent(ContextRefreshedEvent event) {
1626
log.info(" =========================== ");
1727
log.info(" === Application Started === ");
1828
log.info(" =========================== ");
29+
this.categoryRepository.deleteAll();
30+
this.categoryRepository.save(new Category("www"));
31+
this.categoryRepository.save(new Category("qt4"));
32+
this.categoryRepository.save(new Category("qt5"));
33+
// fetch all Categories
34+
log.info("Categories found with findAll():");
35+
log.info("--------------------------------");
36+
for (Category category : this.categoryRepository.findAll()) {
37+
log.info(category.toString());
38+
}
39+
System.out.println();
40+
log.info("fetch an individual Category: ");
41+
log.info("Category found with findByCategory('www'):");
42+
log.info("--------------------------------");
43+
log.info(this.categoryRepository.findByName("www").toString());
1944
}
2045
}

0 commit comments

Comments
 (0)