spring-boot-talk



spring-boot-talk

0 1


spring-boot-talk


On Github KevinGreene / spring-boot-talk

Making Java Development Fast and Fun

Kevin Greene

@SurrealAnalysis

In the beginning

...well, 2004

<?xml version="1.0" encoding="UTF-8"?>

And it was great!

It definitely improved on what was there before Provided excellent DI

But...

Featured lots of XM Slow development Slow deployment Lots of conventions Lots of configuration And in the same year...

Configuration is dead!

Long live convention!

Long live fun programming languages!

And it was great!

Fast CRUD development Easy deploys Great library support Gem install anything!

But...

Scaling things is hard Applications need custom content CoffeeScript is bad SPAs are the future Rails is slow Nokigiri is the worst thing to install

Convention is dead!

Long live configuration!

Long live microframeworks!

And it was great!

Microservices became easy to write Asyncronous code provided real benefits WebSockets are easy and fast

But...

Asynchronous code often lead to callback hell JavaScript isn't the best language out there Can only use one thread at a time CRUD generation is worse than Rails

We need a solution that...

allows someone to easily write a microservice

also has support for easy CRUD

has great library support

can easily do anything needed

Meanwhile in Java-land...

Spring eliminated the need for most XML (2008), and eventually all (2012)

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

  @Autowired
  public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
    .inMemoryAuthentication()
    .withUser("user").password("password").roles("USER");
  }
}

Annotations and improvements made JPA and Hibernate easily readable

@Entity
public class Customer {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;
    private String firstName;
    private String lastName;

    protected Customer() {}
};

Single class-style coding lets you write code just as unorganized as NodeJS

STILL NEED EXAMPLE HERE

Java got better

List<String> organizers =
    Arrays.asList("Kevin", "Carlus", "Galen");

organizers
    .stream()
    .filter(s -> s.endsWith("n"))
    .map(String::toLowerCase)
    .sorted()
    .forEach(System.out::println);
This is easily parallelizable This is lazy

No more excuses

DevTools are analogous to rerun in Ruby Spring Loaded allows you to hotload code

Deploying got easier

Uberjars make deploying significantly easier. Spring Boot now embeds a Tomcat container, making everything just work with java -jar

Profiles

@Configuration
@Profile("dev")
public class StandaloneDataConfig {

    @Bean
    public DataSource dataSource() {
        return new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.HSQL)
            .addScript("classpath:com/bank/config/sql/schema.sql")
            .addScript("classpath:com/bank/config/sql/test-data.sql")
            .build();
    }
};
@Configuration
@Profile("production")
public class JndiDataConfig {

    @Bean(destroyMethod="")
    public DataSource dataSource() throws Exception {
        Context ctx = new InitialContext();
        return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
    }
}

Some great companies threw their weight behind Spring

And if you hate Java still...

Groovy

Great language Speed comparable to Java What to use if you like what Ruby brings to the table

Kotlin

Great language Speed comparable to Java What to use if you like what Scala brings to the table

What is it?

Spring Boot is just an opinionated collection of Spring libraries, with starter kits and command-line runners

...but what is Spring?

Spring is just a collection of useful Java libraries that cohesively come together for web development (and more)

Spring IO standardizes the version of Spring + common libraries

Also, many times, when I / others say Spring Boot, they just mean modern Spring

How do I start?

http://start.spring.io/

Rest API

Rails can quickly generate a useful REST API.

Let's see what Spring Boot looks like?

An Entity

@Entity
public class Character

A Repository

A Main Application

Done!

It'd be better if...

  • You used Groovy
  • Lombok worked

Simple Sockets

Something to send

Someplace to send it

Some minor config

Some HTML / JS

DNS

Warning: This demo is lacking

A server

@EnableEurekaServer

A client

@EnableEurekaServer

Crud

Five commands to make an app

yo jhipster
yo jhipster:entity Skill
yo jhipster:entity Employee
gulp
mvn springBoot:run

Miscellaneous

There are a few things to check out Definitely worth your time Didn't have time to make sample apps

Batch

Spring Batch is a simple and effective interface Reader -> Processor -> Writer I've used it at most jobs off and on Can be combined with Quartz for scheduling

NoSQL

Grails

Your turn

start.spring.io

spring.io/guides

Questions?

Making Java Development Fast and Fun Kevin Greene @SurrealAnalysis