Skip to content

Commit 2a66156

Browse files
committed
Revert "clean"
This reverts commit cf29513.
1 parent cf29513 commit 2a66156

File tree

5 files changed

+25
-36
lines changed

5 files changed

+25
-36
lines changed

app/pom.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<artifactId>com.hellokoding</artifactId>
5-
<name>dockercompose-springboot-mysql-nginx</name>
6-
<description>dockercompose-springboot-mysql-nginx</description>
5+
<name>dockercompose-springboot-mongodb-nginx</name>
6+
<description>dockercompose-springboot-mongodb-nginx</description>
77
<parent>
88
<groupId>org.springframework.boot</groupId>
99
<artifactId>spring-boot-starter-parent</artifactId>
@@ -20,12 +20,9 @@
2020
<artifactId>spring-boot-starter-freemarker</artifactId>
2121
</dependency>
2222
<dependency>
23-
<groupId>org.springframework.boot</groupId>
24-
<artifactId>spring-boot-starter-data-jpa</artifactId>
25-
</dependency>
26-
<dependency>
27-
<groupId>mysql</groupId>
28-
<artifactId>mysql-connector-java</artifactId>
23+
<groupId>org.mongodb</groupId>
24+
<artifactId>mongodb-driver</artifactId>
25+
<version>3.6.1</version>
2926
</dependency>
3027
</dependencies>
3128
<build>

app/src/main/java/com/hellokoding/springboot/IndexController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.hellokoding.springboot;
22

3+
import com.mongodb.MongoClient;
34
import org.springframework.stereotype.Controller;
45
import org.springframework.ui.Model;
56
import org.springframework.web.bind.annotation.GetMapping;
67

8+
import java.util.logging.Level;
79
import java.util.logging.Logger;
810

911
@Controller
@@ -12,6 +14,8 @@ public class IndexController {
1214

1315
@GetMapping("/")
1416
public String index(Model model) {
17+
MongoClient mongoClient = new MongoClient("mongodb");
18+
logger.log(Level.INFO, "First database name: " + mongoClient.listDatabaseNames().first());
1519
return "index";
1620
}
1721
}
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
11
spring.freemarker.template-loader-path: classpath:/templates
2-
spring.freemarker.suffix: .ftl
3-
4-
spring.datasource.url=jdbc:mysql://mysql:3306/test?useSSL=false
5-
spring.datasource.username=root
6-
spring.datasource.password=hellokoding
7-
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
8-
9-
spring.jpa.hibernate.ddl-auto=create
10-
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
11-
spring.jpa.generate-ddl=true
12-
spring.jpa.show-sql=true
2+
spring.freemarker.suffix: .ftl

app/src/main/resources/templates/index.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Docker Compose with Spring Boot, MySQL, NGINX</title>
5+
<title>Docker Compose with Spring Boot, MongoDB, NGINX</title>
66
</head>
77
<body>
8-
<h1>Docker Compose with Spring Boot, MySQL, NGINX</h1>
8+
<h1>Docker Compose with Spring Boot, MongoDB, NGINX</h1>
99
<p></p>
1010
</body>
1111
</html>

docker-compose.yaml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ services:
99
- 443:443
1010
volumes:
1111
- ./nginx/conf.d:/etc/nginx/conf.d
12-
13-
mysql:
14-
container_name: some-mysql
15-
image: mysql/mysql-server:5.7
16-
environment:
17-
MYSQL_DATABASE: test
18-
MYSQL_ROOT_PASSWORD: hellokoding
19-
MYSQL_ROOT_HOST: '%'
20-
ports:
21-
- "3306:3306"
22-
# volumes:
23-
# - ./data/mysql:/var/lib/mysql
24-
restart: always
25-
12+
mongodb:
13+
container_name: some-mongo
14+
image: mongo:3.6
15+
environment:
16+
- MONGO_DATA_DIR=/data/db
17+
- MONGO_LOG_DIR=/dev/null
18+
volumes:
19+
- ./data/db:/data/db
20+
ports:
21+
- 27017:27017
22+
command: mongod --smallfiles --logpath=/dev/null # --quiet
23+
2624
app:
2725
restart: always
2826
build: ./app
@@ -35,4 +33,4 @@ services:
3533
command: mvn clean spring-boot:run
3634
depends_on:
3735
- nginx
38-
- mysql
36+
- mongodb

0 commit comments

Comments
 (0)