Skip to content

Commit 79e5331

Browse files
spring boot upgrade to 2.1.5.RELEASE
1 parent d4f5795 commit 79e5331

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+821
-115
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020

2121
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2222
hs_err_pid*
23+
24+
.vscode/*
25+
.vscode

airtel-store-service/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM openjdk:8-jdk-alpine
2-
MAINTAINER BARATH
2+
RUN adduser demo
3+
USER demo
34
VOLUME /tmp
45
ADD target/airtel-store-service-*.jar app.jar
56
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

airtel-store-service/pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.barath.microservices</groupId>
77
<artifactId>airtel-store-service</artifactId>
8-
<version>3.0.0-SNAPSHOT</version>
8+
<version>3.0.0.RELEASE</version>
99
<packaging>jar</packaging>
1010

1111
<name>airtel-store-service</name>
@@ -14,14 +14,15 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.3.RELEASE</version>
17+
<version>2.1.5.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
25+
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
2526
</properties>
2627

2728
<dependencies>
@@ -43,6 +44,10 @@
4344
<artifactId>spring-boot-devtools</artifactId>
4445
<scope>runtime</scope>
4546
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.cloud</groupId>
49+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
50+
</dependency>
4651
<dependency>
4752
<groupId>org.hsqldb</groupId>
4853
<artifactId>hsqldb</artifactId>
@@ -63,6 +68,17 @@
6368
</plugin>
6469
</plugins>
6570
</build>
71+
<dependencyManagement>
72+
<dependencies>
73+
<dependency>
74+
<groupId>org.springframework.cloud</groupId>
75+
<artifactId>spring-cloud-dependencies</artifactId>
76+
<version>${spring-cloud.version}</version>
77+
<type>pom</type>
78+
<scope>import</scope>
79+
</dependency>
80+
</dependencies>
81+
</dependencyManagement>
6682

6783

6884
</project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

66
@SpringBootApplication
7-
public class AirtelStoreServiceApplication {
7+
public class Application {
88

99
public static void main(String[] args) {
10-
SpringApplication.run(AirtelStoreServiceApplication.class, args);
10+
SpringApplication.run(Application.class, args);
1111
}
1212
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.barath.airtel.app.configuration;
2+
3+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.Profile;
6+
7+
@Profile("eureka")
8+
@Configuration
9+
@EnableDiscoveryClient
10+
public class EurekaConfiguration {
11+
12+
}

airtel-store-service/src/main/java/com/barath/airtel/app/configuration/RouterConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
/**
17-
* Created by barath on 03/03/18.
17+
* @author barath
1818
*/
1919
@Configuration
2020
public class RouterConfiguration {
@@ -29,9 +29,9 @@ public RouterConfiguration(CustomerHandler customerHandler){
2929
public RouterFunction<ServerResponse> routes(){
3030

3131
return RouterFunctions
32-
.route(POST("/customer/add")
32+
.route(POST("/customer")
3333
.and(accept(MediaType.APPLICATION_JSON_UTF8)),customerHandler::addCustomer)
34-
.andRoute(GET("/customer/get/{customerName}"),customerHandler::getCustomer)
34+
.andRoute(GET("/customer/{customerName}"),customerHandler::getCustomer)
3535
.andRoute(GET("/customers"),customerHandler::getCustomers);
3636

3737
}

airtel-store-service/src/main/java/com/barath/airtel/app/entity/Customer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import javax.persistence.*;
77

88
/**
9-
* Created by barath on 03/03/18.
9+
* @author barath
1010
*/
1111
@Entity
1212
@Table(name = "CUSTOMER")

airtel-store-service/src/main/java/com/barath/airtel/app/handler/CustomerHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
package com.barath.airtel.app.handler;
22

3-
import com.barath.airtel.app.entity.Customer;
4-
import com.barath.airtel.app.service.CustomerService;
3+
import java.lang.invoke.MethodHandles;
4+
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
77
import org.springframework.http.MediaType;
88
import org.springframework.stereotype.Component;
99
import org.springframework.web.reactive.function.server.ServerRequest;
1010
import org.springframework.web.reactive.function.server.ServerResponse;
11-
import reactor.core.publisher.Mono;
1211

13-
import java.lang.invoke.MethodHandles;
12+
import com.barath.airtel.app.entity.Customer;
13+
import com.barath.airtel.app.service.CustomerService;
14+
15+
import reactor.core.publisher.Mono;
1416

1517
/**
16-
* Created by barath on 03/03/18.
18+
* @author barath
1719
*/
18-
1920
@Component
2021
public class CustomerHandler {
2122

airtel-store-service/src/main/java/com/barath/airtel/app/repository/CustomerRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.springframework.data.jpa.repository.JpaRepository;
55

66
/**
7-
* Created by barath on 03/03/18.
7+
* @author barath
88
*/
99
public interface CustomerRepository extends JpaRepository<Customer,Long> {
1010

airtel-store-service/src/main/java/com/barath/airtel/app/service/CustomerService.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
package com.barath.airtel.app.service;
22

3-
import com.barath.airtel.app.entity.Customer;
4-
import com.barath.airtel.app.repository.CustomerRepository;
3+
import java.lang.invoke.MethodHandles;
4+
import java.util.Arrays;
5+
6+
import javax.annotation.PostConstruct;
57

68
import org.slf4j.Logger;
79
import org.slf4j.LoggerFactory;
810
import org.springframework.stereotype.Service;
11+
12+
import com.barath.airtel.app.entity.Customer;
13+
import com.barath.airtel.app.repository.CustomerRepository;
14+
915
import reactor.core.publisher.Flux;
1016
import reactor.core.publisher.Mono;
1117

12-
import javax.annotation.PostConstruct;
13-
import java.lang.invoke.MethodHandles;
14-
import java.util.Arrays;
15-
import java.util.List;
16-
1718
/**
18-
* Created by barath on 03/03/18.
19+
* @author barath
1920
*/
2021
@Service
2122
public class CustomerService {
2223

23-
private CustomerRepository customerRepository;
24+
private final CustomerRepository customerRepository;
2425
private static final Logger logger= LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
2526

2627
public CustomerService(CustomerRepository customerRepository) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eureka:
2+
client:
3+
enabled: true
4+
register-with-eureka: true
5+
fetch-registry: true
6+
service-url:
7+
default-zone: http://localhost:8761/eureka

airtel-store-service/src/main/resources/application.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ spring:
1111
show-sql: true
1212
hibernate:
1313
ddl-auto: create
14+
15+
# disable eureka by default
16+
17+
eureka:
18+
client:
19+
enabled: false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@RunWith(SpringRunner.class)
99
@SpringBootTest
10-
public class AirtelStoreServiceApplicationTests {
10+
public class ApplicationTests {
1111

1212
@Test
1313
public void contextLoads() {

config-server/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM openjdk:8-jdk-alpine
2-
MAINTAINER BARATH
2+
RUN adduser -D demo
3+
USER demo
34
VOLUME /tmp
45
ADD target/config-server-*.jar app.jar
56
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

config-server/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.barath.microservices</groupId>
77
<artifactId>config-server</artifactId>
8-
<version>3.0.0-SNAPSHOT</version>
8+
<version>3.0.0.RELEASE</version>
99
<packaging>jar</packaging>
1010

1111
<name>config-server</name>
@@ -14,15 +14,15 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.3.RELEASE</version>
17+
<version>2.1.5.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
25-
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
25+
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
2626
</properties>
2727

2828
<dependencies>

docker-compose.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
version: '3'
2-
services:
3-
config-server-service:
2+
services:
3+
eureka-server:
4+
build: ./eureka-server
5+
image: barathece91/eureka-server-k8s
6+
ports:
7+
- "8761:8761"
8+
config-server:
49
build: ./config-server
510
image: barathece91/config-server-k8s
611
ports:

eureka-server/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
12+
### IntelliJ IDEA ###
13+
.idea
14+
*.iws
15+
*.iml
16+
*.ipr
17+
18+
### NetBeans ###
19+
nbproject/private/
20+
build/
21+
nbbuild/
22+
dist/
23+
nbdist/
24+
.nb-gradle/
46.5 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip

eureka-server/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM openjdk:8-jdk-alpine
2+
RUN adduser -D demo
3+
USER demo
4+
ADD target/eureka-server-*.jar app.jar
5+
ENTRYPOINT ["java","-jar","app.jar"]
6+

eureka-server/Dockerfile.build

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# Builder stage
3+
FROM maven:3.5-jdk-8 as builder
4+
WORKDIR /opt
5+
COPY . /opt
6+
RUN mvn clean install
7+
8+
9+
# Final stage
10+
11+
FROM openjdk:8-jdk-alpine as final
12+
# best practice is not to use root user
13+
RUN adduser -D demo
14+
USER demo
15+
COPY --from=builder /opt/target/eureka-server-*.jar app.jar
16+
ENTRYPOINT ["java","-jar","app.jar"]
17+

eureka-server/manifest.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
applications:
3+
- name: eureka-server
4+
memory: 1024M
5+
buildpack: java_buildpack
6+
path: target/eureka-server-2.0.3.RELEASE.jar
7+
services:
8+
- config-client
9+
env:
10+
SPRING_PROFILES_ACTIVE: pcfdev
11+
#SPRING_PROFILES_ACTIVE: pcf

0 commit comments

Comments
 (0)