Updated Employee

This commit is contained in:
Saikat Chakraborty 2022-09-21 22:53:50 +05:30
parent 98bc9c336b
commit 40013de660
3 changed files with 8 additions and 4 deletions

View File

@ -32,4 +32,4 @@ keytool -importcert -alias MySQLCACert.jks -file root-ca.pem \
-keystore truststore.jks -storepass mypassword
openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -out certificate.p12 -name "certificate"
keytool -importkeystore -srckeystore certificate.p12 -srcstoretype pkcs12 -destkeystore cert.jks
keytool -importkeystore -srckeystore certificate.p12 -srcstoretype pkcs12 -destkeystore client-cert.jks

View File

@ -2,6 +2,9 @@ package com.baeldung.boot.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import java.util.Optional;
@RestController
public class EmployeeController {
@ -11,7 +14,8 @@ public class EmployeeController {
@GetMapping("/employee/{empId}")
public Employee get(@PathVariable(name = "empId") Integer empId) {
return empRepository.findById(empId).get();
Optional<Employee> emp = empRepository.findById(empId);
return emp.orElse(null);
}
@PostMapping("/employee")

View File

@ -26,10 +26,10 @@ spring:
profiles: "dev2"
datasource:
url: >-
jdbc:mysql://localhost:3306/test_db?sslMode=VERIFY_IDENTITY&
jdbc:mysql://localhost:3306/test_db?sslMode=VERIFY_CA&
trustCertificateKeyStoreUrl=file:/Users/saikatchakraborty/tutorials/persistence-modules/spring-boot-mysql/mysql-server/certs/truststore.jks&
trustCertificateKeyStorePassword=mypassword&
clientCertificateKeyStoreUrl=file:/Users/saikatchakraborty/tutorials/persistence-modules/spring-boot-mysql/mysql-server/certs/cert.jks&
clientCertificateKeyStoreUrl=file:/Users/saikatchakraborty/tutorials/persistence-modules/spring-boot-mysql/mysql-server/certs/client-cert.jks&
clientCertificateKeyStorePassword=mypassword
username: test_user
password: Password2022