Skip to content

sashinpivotal/spring-boot2-student-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 

Repository files navigation

Reference materials

In addition to the standard course contents, we might use some extra reference materials below whenever needed:

Microservices

The 12 Factors App

App Continuum

Event-driven architecture

Spring Data JDBC presentations

REST

Spring MVC and REST

RestTemplate

  • Javadoc

  • RestTemplate Customization

  • Tutorial

  • Example of a Spring Cloud Load Balanced Rest Template customized with timeout:

        /**
         * RestTemplate Builder
         *
         * Following example sets connect timeout of 500ms,
         * where if client cannot acquire open connection on a socket,
         * it will time out.
         *
         * Operations that timeout on connect events may be retried without
         * regard to Idempotence.
         *
         * The example also shows how to configure the read timeout to 2
         * seconds.
         * This protects the calling client from long running calls in a
         * downstream server/producer.
         *
         * Retries may only be executed across read timeouts if the down
         * stream operation is idempotent,
         * use with care.
         *
         * @return RestTemplate
         */
        @LoadBalanced
        @Bean
        public RestTemplate restTemplate() {
            return new RestTemplateBuilder()
                    .setConnectTimeout(Duration.ofMillis(500L))
                    .setReadTimeout(Duration.ofMillis(2000L))
                    .build();
        }

How to run HSQLDB Client

  • Add the following configuration class
import org.hsqldb.util.DatabaseManagerSwing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

@Configuration
public class HsqldbConfig {

    @Autowired
    DataSource dataSource;

    @Bean
    public JdbcTemplate getJdbcTemplate(){
        return new JdbcTemplate(dataSource);
    }

    //default username : sa, password : ''
    @PostConstruct
    public void getDbManager(){
        DatabaseManagerSwing.main(
                new String[] { "--url", "jdbc:hsqldb:mem:testdb", "--user", "sa", "--password", ""});
    }
}
  • Turn off the "java.awt.headless"
	System.setProperty("java.awt.headless", "false");

Actuator

Actuator/Prometheus lab

Spring Boot Testing

OAuth2

Spring Cloud Contract

Tools

Spring related

  • Spring Lifecycle changes with Spring 5.+ and Java 11

    • Java 11 Drops JSR 250 Annotations, including @PostConstruct & @PreDestroy. See Java 11 Migration Guide and Spring Framework docs

    • If using Java 11, you may explicitly import annotations:

      implementation 'javax.annotation:javax.annotation-api:1.3.2'
      <dependency>
         <groupId>javax.annotation</groupId>
         <artifactId>javax.annotation-api</artifactId>
         <version>1.3.2</version>
      </dependency>
      
    • Or, you may use @Bean parameters to specific init and cleanup callbacks, see Spring Lifecycle Callbacks for more examples.

    • You may also implement the InitializingBean or DisposableBean on the class you want to provide the lifecycle callbacks, but this ties your class to Spring.

Spring Performance Considerations

Spring Boot 1.5 -> 2.0 Migration Considerations

Microservices & Fault Tolerance Patterns

Certification

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published