An example of a Spring-Boot application, which based on the port and adapters/hexagonal architecture and DDD.
Build Status | License |
---|---|
The whole component scan for the adapter package is excluded in the application, so the unnecessary adapter beans won't be loaded into the application context, just the configured ones. Each adapter defines her own spring configuration class, which is imported via the @Import annotation (on top of the application's main class) but getting only component scanned if the condition fulfills for it via @ConditionalOnProperty annotation.
Based on the below example if you define "spring-data-jpa" value as a persistence adapter in the application-[profile].yml, then it will activate the corresponding Configuration class, which is going to component scan the underlying packages for spring beans.
@Configuration
@EnableJpaRepositories
@ComponentScan
@ConditionalOnProperty(
value = "adapter.persistence",
havingValue = "spring-data-jpa"
)
public class JpaPersistenceConfiguration {
}
application-[profile].yml
adapter:
authentication: basic
persistence: spring-data-jpa
messaging: spring-event-bus
web: rest
mvn clean verify
**Building and verifying the application requires a running docker, since some tests are using Testcontainers library!
Test catalog type | Maven lifecycle |
---|---|
Unit test | test |
Component test | test |
ArchUnit test | test |
Integration test | verify |
Functional test | verify |
You can access the API documentation locally at the following URL: