forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bael 5543 - Running a spring boot app without DB (eugenp#12339)
* BAEL-5543 - Running a spring boot app without db * BAEL-5543 - Adding authentication properties * BAEL-5543 - Moving to a new module * BAEL-5543 - Changing test class name * BAEL-5543 - Reducing Java version Co-authored-by: Abhinav Pandey <[email protected]>
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### Relevant Articles: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.baeldung.spring-boot-modules</groupId> | ||
<artifactId>spring-boot-modules</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.baeldung</groupId> | ||
<artifactId>spring-boot-data-3</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-boot-data-3</name> | ||
<description>spring-boot-data-3</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...ring-boot-data-3/src/main/java/com/baeldung/startwithoutdb/StartWithoutDbApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
spring-boot-modules/spring-boot-data-3/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
24 changes: 24 additions & 0 deletions
24
...-boot-data-3/src/test/java/com/baeldung/startwithoutdb/StartWithoutDbIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
|
||
} |