-
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.
- docker-compose.yml added for local development - profiling added - connection mongo db established
- Loading branch information
Ramachandran Nellaiyappan
committed
Mar 10, 2024
1 parent
f6bc830
commit bbe1c2b
Showing
10 changed files
with
146 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: "3.8" | ||
services: | ||
mongodb: | ||
image: mongo | ||
container_name: mongo | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- data:/data | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=mongodb_user | ||
- MONGO_INITDB_ROOT_PASSWORD=mongodb_pwd | ||
|
||
mongo-express: | ||
image: mongo-express | ||
container_name: mongo-express | ||
restart: always | ||
ports: | ||
- "9090:8081" | ||
environment: | ||
- ME_CONFIG_MONGODB_ADMINUSERNAME=mongodb_user | ||
- ME_CONFIG_MONGODB_ADMINPASSWORD=mongodb_pwd | ||
- ME_CONFIG_MONGODB_SERVER=mongo | ||
- ME_CONFIG_MONGODB_AUTH_USERNAME=admin | ||
- ME_CONFIG_MONGODB_AUTH_PASSWORD=pass | ||
|
||
volumes: | ||
data: {} | ||
|
||
networks: | ||
default: | ||
name: mongodb_network | ||
|
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
24 changes: 21 additions & 3 deletions
24
src/main/java/com/github/nramc/dev/journey/api/JourneyApiApplication.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 |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package com.github.nramc.dev.journey.api; | ||
|
||
import com.github.nramc.dev.journey.api.data.entity.LocationEntity; | ||
import com.github.nramc.dev.journey.api.data.repository.LocationRepository; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@SpringBootApplication | ||
@Slf4j | ||
public class JourneyApiApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(JourneyApiApplication.class, args); | ||
} | ||
public static void main(String[] args) { | ||
SpringApplication.run(JourneyApiApplication.class, args); | ||
} | ||
|
||
@Bean | ||
CommandLineRunner commandLineRunner(LocationRepository locationRepository) { | ||
return args -> { | ||
LocationEntity entity = new LocationEntity("Munich"); | ||
locationRepository.save(entity); | ||
|
||
log.info("Number of documents found: {}", locationRepository.count()); | ||
|
||
locationRepository.findAll().forEach(location -> log.info("Found: {}", location)); | ||
}; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/github/nramc/dev/journey/api/data/entity/LocationEntity.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,18 @@ | ||
package com.github.nramc.dev.journey.api.data.entity; | ||
|
||
import lombok.Data; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
@Document("location") | ||
@Data | ||
public class LocationEntity { | ||
@Id | ||
private String id; | ||
|
||
private String name; | ||
|
||
public LocationEntity(String name) { | ||
this.name = name; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/github/nramc/dev/journey/api/data/repository/LocationRepository.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,7 @@ | ||
package com.github.nramc.dev.journey.api.data.repository; | ||
|
||
import com.github.nramc.dev.journey.api.data.entity.LocationEntity; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface LocationRepository extends MongoRepository<LocationEntity, String> { | ||
} |
Empty file.
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: | ||
data: | ||
mongodb: | ||
database: ${DATABASE_NAME} | ||
uri: ${MONGODB_CONNECTION_URL} | ||
|
||
|
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
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