Bael 5543 - Running a spring boot app without DB (#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]>
This commit is contained in:
committed by
GitHub
co-authored by
Abhinav Pandey
parent
405578bfb5
commit
a5ddb7dd9c
+13
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user