diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 29685b0eb8..d0a35859b4 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -77,6 +77,7 @@ spring-boot-actuator spring-boot-data-2 spring-boot-validation + spring-boot-data-3 diff --git a/spring-boot-modules/spring-boot-data-3/README.md b/spring-boot-modules/spring-boot-data-3/README.md new file mode 100644 index 0000000000..7d843af9ea --- /dev/null +++ b/spring-boot-modules/spring-boot-data-3/README.md @@ -0,0 +1 @@ +### Relevant Articles: diff --git a/spring-boot-modules/spring-boot-data-3/pom.xml b/spring-boot-modules/spring-boot-data-3/pom.xml new file mode 100644 index 0000000000..a4fcd0c3f3 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-3/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + + com.baeldung + spring-boot-data-3 + 0.0.1-SNAPSHOT + spring-boot-data-3 + spring-boot-data-3 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + mysql + mysql-connector-java + runtime + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-modules/spring-boot-data-3/src/main/java/com/baeldung/startwithoutdb/StartWithoutDbApplication.java b/spring-boot-modules/spring-boot-data-3/src/main/java/com/baeldung/startwithoutdb/StartWithoutDbApplication.java new file mode 100644 index 0000000000..6137113535 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-3/src/main/java/com/baeldung/startwithoutdb/StartWithoutDbApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.startwithoutdb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class StartWithoutDbApplication { + + public static void main(String[] args) { + SpringApplication.run(StartWithoutDbApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-data-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-data-3/src/main/resources/application.properties new file mode 100644 index 0000000000..cbe044134f --- /dev/null +++ b/spring-boot-modules/spring-boot-data-3/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost:3306/myDb +spring.datasource.username=root +spring.datasource.password=root +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +spring.jpa.hibernate.ddl-auto=none +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data-3/src/test/java/com/baeldung/startwithoutdb/StartWithoutDbIntegrationTest.java b/spring-boot-modules/spring-boot-data-3/src/test/java/com/baeldung/startwithoutdb/StartWithoutDbIntegrationTest.java new file mode 100644 index 0000000000..74d07848a0 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-3/src/test/java/com/baeldung/startwithoutdb/StartWithoutDbIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.startwithoutdb; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.sql.DataSource; + +@SpringBootTest(classes = StartWithoutDbApplication.class) +class StartWithoutDbIntegrationTest { + + @Autowired + private ApplicationContext context; + + @Test + public void givenAutoConfigDisabled_whenStarting_thenNoAutoconfiguredBeansInContext() { + context.getBean(DataSource.class); + } + + +}