diff --git a/03.microservices/git-localconfig-repo b/03.microservices/git-localconfig-repo
index b0670f28..d39e38f6 160000
--- a/03.microservices/git-localconfig-repo
+++ b/03.microservices/git-localconfig-repo
@@ -1 +1 @@
-Subproject commit b0670f28ce80ffc550a4e553b27f1e88f30005e4
+Subproject commit d39e38f6ac2764b187de9edefad6fd93b3ee15d6
diff --git a/03.microservices/limits-service/pom.xml b/03.microservices/limits-service/pom.xml
index b47ab38b..addafd55 100644
--- a/03.microservices/limits-service/pom.xml
+++ b/03.microservices/limits-service/pom.xml
@@ -14,15 +14,15 @@
org.springframework.boot
spring-boot-starter-parent
- 2.0.0.M3
-
+ 1.5.2.RELEASE
+
UTF-8
UTF-8
1.8
- Finchley.M2
+ Dalston.RC1
@@ -30,6 +30,11 @@
org.springframework.cloud
spring-cloud-starter-config
+
+ org.springframework.cloud
+ spring-cloud-starter-bus-amqp
+
+
org.springframework.boot
spring-boot-starter-web
diff --git a/03.microservices/limits-service/src/main/java/com/in28minutes/microservices/limitsservice/LimitsConfigurationController.java b/03.microservices/limits-service/src/main/java/com/in28minutes/microservices/limitsservice/LimitsConfigurationController.java
index e2ef9bb0..3ff601bd 100644
--- a/03.microservices/limits-service/src/main/java/com/in28minutes/microservices/limitsservice/LimitsConfigurationController.java
+++ b/03.microservices/limits-service/src/main/java/com/in28minutes/microservices/limitsservice/LimitsConfigurationController.java
@@ -14,8 +14,8 @@ public class LimitsConfigurationController {
@GetMapping("/limits")
public LimitConfiguration retrieveLimitsFromConfigurations() {
- return new LimitConfiguration(configuration.getMaximum(),
+ LimitConfiguration limitConfiguration = new LimitConfiguration(configuration.getMaximum(),
configuration.getMinimum());
+ return limitConfiguration;
}
-
}
diff --git a/03.microservices/limits-service/src/main/resources/bootstrap.properties b/03.microservices/limits-service/src/main/resources/bootstrap.properties
index 614cc9b9..c1ff7971 100644
--- a/03.microservices/limits-service/src/main/resources/bootstrap.properties
+++ b/03.microservices/limits-service/src/main/resources/bootstrap.properties
@@ -1,3 +1,4 @@
spring.application.name=limits-service
spring.cloud.config.uri=http://localhost:8888
-spring.profiles.active=qa
\ No newline at end of file
+spring.profiles.active=qa
+management.security.enabled=false
\ No newline at end of file
diff --git a/03.microservices/spring-cloud-config-server/pom.xml b/03.microservices/spring-cloud-config-server/pom.xml
index 89e966da..8f481759 100644
--- a/03.microservices/spring-cloud-config-server/pom.xml
+++ b/03.microservices/spring-cloud-config-server/pom.xml
@@ -14,7 +14,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.0.0.M3
+ 1.5.2.RELEASE
@@ -22,7 +22,7 @@
UTF-8
UTF-8
1.8
- Finchley.M2
+ Dalston.RC1
@@ -31,6 +31,11 @@
spring-cloud-config-server
+
+ org.springframework.cloud
+ spring-cloud-starter-bus-amqp
+
+
org.springframework.boot
spring-boot-starter-test
diff --git a/step42.md b/step42.md
new file mode 100644
index 00000000..b14bfc8c
--- /dev/null
+++ b/step42.md
@@ -0,0 +1,3565 @@
+
+## Complete Code Example
+
+
+### /01.framework-introductions/jpa-in-10-steps/notes.txt
+
+```
+Questions
+- Where is the database created?
+- What schema is used to create the tables?
+- Where are the tables created?
+- Can I see the data in the database?
+- Where is Hibernate coming in from?
+- How is a datasource created?
+
+Magic of Spring Boot and in Memory Database
+- Zero project setup or infrastructure
+- Zero Configuration
+- Zero Maintainance
+- Easy to use for Learning and Unit Tests
+- Simple Configuration to switch to a real database
+
+# Restrictions of using in-memory database
+- Data is not persisted between restarts
+
+Spring Boot chooses a default value for you based on whether it thinks your database is embedded (default create-drop) or not (default none).
+
+HibernateJpaAutoConfiguration matched:
+ - @ConditionalOnClass found required classes 'org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean', 'javax.persistence.EntityManager'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
+ - HibernateEntityManager found class 'org.hibernate.ejb.HibernateEntityManager' (HibernateJpaAutoConfiguration.HibernateEntityManagerCondition)
+
+DataSourceAutoConfiguration matched:
+ - @ConditionalOnClass found required classes 'javax.sql.DataSource', 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
+
+JpaBaseConfiguration#entityManagerFactory matched:
+ - @ConditionalOnMissingBean (types: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean,javax.persistence.EntityManagerFactory; SearchStrategy: all) did not find any beans (OnBeanCondition)
+
+JpaBaseConfiguration#transactionManager matched:
+ - @ConditionalOnMissingBean (types: org.springframework.transaction.PlatformTransactionManager; SearchStrategy: all) did not find any beans (OnBeanCondition)
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/pom.xml
+
+```xml
+
+
+ 4.0.0
+
+ com.in28minutes.learning.jpa
+ jpa-in-10-steps
+ 0.0.1-SNAPSHOT
+ jar
+
+ jpa-in-10-steps
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.BUILD-SNAPSHOT
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/entity/User.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+//Table - User
+@Entity
+public class User {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+
+ private String role;
+
+ protected User() {
+
+ }
+
+ public User(String name, String role) {
+ super();
+ this.name = name;
+ this.role = role;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("User [id=%s, name=%s, role=%s]", id, name, role);
+ }
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/JpaIn10StepsApplication.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class JpaIn10StepsApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(JpaIn10StepsApplication.class, args);
+ }
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/service/UserDAOService.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps.service;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transactional;
+
+import org.springframework.stereotype.Repository;
+
+import com.in28minutes.learning.jpa.jpain10steps.entity.User;
+
+@Repository
+@Transactional
+public class UserDAOService {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public long insert(User user){
+ entityManager.persist(user);
+ return user.getId();
+ }
+}
+
+/*
+ * Spring Data JPA
+ *
+ *
+ *
+ */
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/service/UserRepository.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps.service;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import com.in28minutes.learning.jpa.jpain10steps.entity.User;
+
+public interface UserRepository extends JpaRepository{
+
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/UserDaoServiceCommandLineRunner.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import com.in28minutes.learning.jpa.jpain10steps.entity.User;
+import com.in28minutes.learning.jpa.jpain10steps.service.UserDAOService;
+
+@Component
+public class UserDaoServiceCommandLineRunner implements CommandLineRunner{
+
+ private static final Logger log =
+ LoggerFactory.getLogger(UserDaoServiceCommandLineRunner.class);
+
+ @Autowired
+ private UserDAOService userDaoService;
+
+ @Override
+ public void run(String... arg0) throws Exception {
+ User user = new User("Jack", "Admin");
+ //New User is created : User [id=1, name=Jack, role=Admin]
+ long insert = userDaoService.insert(user);
+ log.info("New User is created : " + user);
+ }
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/java/com/in28minutes/learning/jpa/jpain10steps/UserRepositoryCommandLineRunner.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import com.in28minutes.learning.jpa.jpain10steps.entity.User;
+import com.in28minutes.learning.jpa.jpain10steps.service.UserRepository;
+
+@Component
+public class UserRepositoryCommandLineRunner implements CommandLineRunner{
+
+ private static final Logger log =
+ LoggerFactory.getLogger(UserRepositoryCommandLineRunner.class);
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Override
+ public void run(String... arg0) throws Exception {
+ User user = new User("Jill", "Admin");
+ userRepository.save(user);
+ log.info("New User is created : " + user);
+
+ Optional userWithIdOne = userRepository.findById(1L);
+ log.info("User is retrived : " + userWithIdOne);
+
+ List users = userRepository.findAll();
+ log.info("All Users : " + users);
+ }
+
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/main/resources/application.properties
+
+```properties
+spring.jpa.show-sql=true
+spring.h2.console.enabled=true
+logging.level.org.springframework=debug
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/src/test/java/com/in28minutes/learning/jpa/jpain10steps/JpaIn10StepsApplicationTests.java
+
+```java
+package com.in28minutes.learning.jpa.jpain10steps;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class JpaIn10StepsApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/step-completed.sh
+
+```
+java -cp /ProgrammingExcellence/Workspaces/Rithus.com/ListDirectoryContentInGitFormat/bin test.ListDirectoryContentInGitFormat $PWD >> $1.md
+zip -r $1.zip . -x "target/*" -x ".*/*" -x ".*" -x "*.md" -x "mvn*" -x "*.zip"
+git add *; git commit -m "$1"; git push;
+```
+---
+
+### /01.framework-introductions/jpa-in-10-steps/take-step-backup.sh
+
+```
+java -cp /ProgrammingExcellence/Workspaces/Rithus.com/ListDirectoryContentInGitFormat/bin test.ListDirectoryContentInGitFormat $PWD >> $1.md
+zip -r $1.zip . -x "target/*" -x ".*/*" -x ".*" -x "*.md" -x "mvn*" -x "*.zip"
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/notes.txt
+
+```
+Goals
+Enable building production ready applications quickly
+Provide common non-functional features
+- embedded servers
+- metrics
+- health checks
+- externalized configuration
+
+What Spring Boot is NOT!
+ZERO code generation
+Neither an application server nor a web server
+
+Features
+Quick Starter Projects with Auto Configuration
+ - Web
+ - JPA
+Embedded Servers - Tomcat, Jetty or Undertow
+Production-ready features
+ - metrics and health checks
+ - externalized configuration
+
+
+http://localhost:8080/books => Few hardcoded books
+
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/pom.xml
+
+```xml
+
+
+ 4.0.0
+
+ com.in28minutes.springboot.basics
+ springboot-in-10-steps
+ 0.0.1-SNAPSHOT
+ jar
+
+ springboot-in-10-steps
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.BUILD-SNAPSHOT
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.data
+ spring-data-rest-hal-browser
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/Book.java
+
+```java
+package com.in28minutes.springboot.basics.springbootin10steps;
+
+public class Book {
+ long id;
+ String name;
+ String author;
+
+ public Book(long id, String name, String author) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.author = author;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Book [id=%s, name=%s, author=%s]", id, name, author);
+ }
+
+}
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/BooksController.java
+
+```java
+package com.in28minutes.springboot.basics.springbootin10steps;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class BooksController {
+ @GetMapping("/books")
+ public List getAllBooks() {
+ return Arrays.asList(
+ new Book(1l, "Mastering Spring 5.2", "Ranga Karanam"));
+ }
+}
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/src/main/java/com/in28minutes/springboot/basics/springbootin10steps/SpringbootIn10StepsApplication.java
+
+```java
+package com.in28minutes.springboot.basics.springbootin10steps;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+
+@SpringBootApplication
+public class SpringbootIn10StepsApplication {
+
+ public static void main(String[] args) {
+ ApplicationContext applicationContext =
+ SpringApplication.run(SpringbootIn10StepsApplication.class, args);
+
+ for (String name : applicationContext.getBeanDefinitionNames()) {
+ System.out.println(name);
+ }
+ }
+}
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/src/main/resources/application.properties
+
+```properties
+#logging.level.org.springframework = DEBUG
+management.security.enabled=false
+```
+---
+
+### /01.framework-introductions/springboot-in-10-steps/src/test/java/com/in28minutes/springboot/basics/springbootin10steps/SpringbootIn10StepsApplicationTests.java
+
+```java
+package com.in28minutes.springboot.basics.springbootin10steps;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringbootIn10StepsApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+```
+---
+
+### /02.restful-web-services/pom.xml
+
+```xml
+
+
+ 4.0.0
+
+ com.in28minutes.rest.webservices
+ restful-web-services
+ 0.0.1-SNAPSHOT
+ jar
+
+ restful-web-services
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.M2
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.data
+ spring-data-rest-hal-browser
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-hateoas
+
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.4.0
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.4.0
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
+```
+---
+
+### /02.restful-web-services/src/main/java/com/in28minutes/rest/webservices/restfulwebservices/exception/CustomizedResponseEntityExceptionHandler.java
+
+```java
+package com.in28minutes.rest.webservices.restfulwebservices.exception;
+
+import java.util.Date;
+
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+import com.in28minutes.rest.webservices.restfulwebservices.user.UserNotFoundException;
+
+@ControllerAdvice
+@RestController
+public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @ExceptionHandler(Exception.class)
+ public final ResponseEntity