Skip to content

Commit a4d70d5

Browse files
committed
Example application for structuring a Spring Boot app
1 parent f2b8342 commit a4d70d5

30 files changed

+749
-76
lines changed

pact/pact-spring-provider/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
compile('org.springframework.boot:spring-boot-starter-data-jpa')
2727
compile('org.springframework.boot:spring-boot-starter-web')
2828
compile('com.h2database:h2:1.4.196')
29-
testCompile('au.com.dius:pact-jvm-provider-spring_2.12:3.5.11')
29+
testCompile('au.com.dius:pact-jvm-provider-spring_2.12:3.5.16')
3030
testCompile('junit:junit:4.12')
3131
testCompile('org.springframework.boot:spring-boot-starter-test')
3232
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include 'spring-boot:rabbitmq-event-brokering'
1717
include 'spring-boot:modular:security-module'
1818
include 'spring-boot:modular:booking-module'
1919
include 'spring-boot:modular:application'
20+
include 'spring-boot:spring-boot-testing'
2021

2122
include 'junit:conditions'
2223

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.gradle
2+
/build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
/out/
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/build/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = '2.0.2.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: 'java'
14+
apply plugin: 'eclipse'
15+
apply plugin: 'org.springframework.boot'
16+
apply plugin: 'io.spring.dependency-management'
17+
18+
group = 'reflectoring.io'
19+
version = '0.0.1-SNAPSHOT'
20+
sourceCompatibility = 1.8
21+
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
27+
dependencies {
28+
compile('org.springframework.boot:spring-boot-starter-data-jpa')
29+
compile('org.springframework.boot:spring-boot-starter-web')
30+
compileOnly('org.projectlombok:lombok')
31+
runtime('com.h2database:h2')
32+
testCompile('org.springframework.boot:spring-boot-starter-test')
33+
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
34+
}

spring-boot/spring-boot-testing/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot/spring-boot-testing/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'spring-boot-testing'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.reflectoring;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
package io.reflectoring.booking;
22

33
import io.reflectoring.booking.business.BookingService;
4+
import io.reflectoring.booking.data.BookingRepository;
5+
import io.reflectoring.customer.CustomerConfiguration;
6+
import io.reflectoring.customer.data.CustomerRepository;
7+
import io.reflectoring.flight.FlightConfiguration;
8+
import io.reflectoring.flight.data.FlightService;
9+
import org.springframework.boot.SpringBootConfiguration;
10+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
411
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.ComponentScan;
13+
import org.springframework.context.annotation.Configuration;
14+
import org.springframework.context.annotation.Import;
515
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
6-
import io.reflectoring.booking.data.BookingRepository;
7-
import io.reflectoring.customer.CustomerRepository;
8-
import io.reflectoring.flight.FlightRepository;
16+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
917

10-
@EnableJpaRepositories("re")
18+
@SpringBootConfiguration
19+
@Import({CustomerConfiguration.class, FlightConfiguration.class})
20+
@EnableAutoConfiguration
21+
@ComponentScan
1122
public class BookingConfiguration {
1223

1324
@Bean
14-
public BookingService bookingService(BookingRepository bookingRepository, CustomerRepository customerRepository, FlightRepository flightRepository) {
15-
return new BookingService(bookingRepository, customerRepository, flightRepository);
25+
public BookingService bookingService(
26+
BookingRepository bookingRepository,
27+
CustomerRepository customerRepository,
28+
FlightService flightService) {
29+
return new BookingService(bookingRepository, customerRepository, flightService);
1630
}
1731

1832
}

0 commit comments

Comments
 (0)