Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8
FROM openjdk:17



Expand Down
2 changes: 1 addition & 1 deletion Readme
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Task:
Debug the SpringBoot application by running it inside one container with the connection to the mysql database from another container.

It is a spring boot application for the local bus service.
The database image is already pre-populated and its name is: opavlova/db-mysql:5.7-test
The database image is already pre-populated and its name is: mysql:8.1.0
container mysql port: 3306
db name: DOCKERDB
password: root
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- test

db:
image: mysql:5.7.37
image: mysql:8.1.0
container_name: db
ports:
- "13306:3306"
Expand Down
11 changes: 6 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.8.RELEASE</version>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>

<dependencies>
Expand All @@ -43,10 +43,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/entity/Entitybus.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package entity;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import jakarta.persistence.*;

import javax.persistence.*;
import java.util.Objects;

/**
* Created by Olga Pavlova on 9/16/2016.
Expand Down Expand Up @@ -44,7 +43,7 @@ public boolean equals(Object o) {
Entitybus entitybus = (Entitybus) o;

if (eid != entitybus.eid) return false;
if (enumber != null ? !enumber.equals(entitybus.enumber) : entitybus.enumber != null) return false;
if (!Objects.equals(enumber, entitybus.enumber)) return false;

return true;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rep/EntitybusRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
import entity.Entitybus;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface EntitybusRepository extends CrudRepository<Entitybus, Long> {
}
4 changes: 1 addition & 3 deletions src/main/java/rest/EntitybusController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.springframework.web.bind.annotation.RestController;
import rep.EntitybusRepository;

import java.util.Random;

@RestController
@RequestMapping("/entitybus")
public class EntitybusController {
Expand All @@ -23,7 +21,7 @@ public Iterable findAll1() {
@RequestMapping("/post")
public Iterable postEntity() {
Entitybus o = new Entitybus();
int num = (int) (Math.random()*10);
int num = (int) (Math.random() * 10);
o.setEid(num);
o.setEnumber("blah" + num);
entitybusRepository.save(o);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
spring.jpa.hibernate.ddl-auto=none

#use it for running all (app and db) in docker containers:
spring.datasource.url=jdbc:mysql://db:3306/DOCKERDB
spring.datasource.url=jdbc:mysql://localhost:13306/DOCKERDB

#use it for running app locally, but with db from docker image:
#spring.datasource.url=jdbc:mysql://0.0.0.0:13306/DOCKERDB

spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect