Welcome, Java Hipster

Yeoman + Maven + Spring + AngularJS in one handy generator

http://jhipster.github.io

Press the right arrow to continue >

About this presentation

  • Hit the left/right arrow to browse to the main sections
  • Hit the up/down arrow to see the slides in each section
  • Hit the "escape" key to see all the slides

What is this all about?

Modern Web application development

Modern Web apps

End-users requirements have evolved. People are tired of slow, unreactive Web sites. They want:

  • Beautiful design
  • Stop waiting for pages to load
  • Dynamic updates of page fragments

We need to use the latest HTML5/CSS3/JavaScript technologies

Developer productivity

Those websites should be delivered fast.

Waiting 1 minute for your application to "deploy" is not acceptable anymore


We need the right tools for this job!

Production-ready software

Modern websites should be able to handle huge numbers of concurrent users

All using massive RESTful applications, which will hit your back-end servers hard


We need robust, high-performance servers

Our goal is to solve those issues


  • A beautiful front-end, with the latest HTML5/CSS3/JavaScript frameworks
  • A robust and high-quality back-end, with the latest Java/Caching/Data access technologies
  • All automatically wired up, with security and performance in mind
  • And great developer tooling, for maximum productivity

Client-side technologies

Yeoman, Grunt, Bower, AngularJS

Yeoman

Yeoman provides application generators

  • Hundreds of generators are available
  • Mostly geared toward JavaScript front-end applications
  • The top-rated generators have excellent quality
							yo jhipster
						

Grunt

Grunt is a JavaScript task runner

  • For development, it will allow you to have "live editing" of your code, run your tests in the background...
  • For production, it will compress and optimize all your resources, compile your Sass code...
							grunt test
						

Bower

Bower is a package manager for your JavaScript assets

  • You can search, install and update your JavaScript libraries
  • It provides a huge number of libraries
							bower install angular
						

Karma

Karma runs unit tests on your JavaScript code

  • It works with Phantom.js, a headless browser
  • It is very fast, and can run continously in the background
							karma start src/test/javascript/karma.conf.js
						

AngularJS

The most popular JavaScript framework

  • Powerful & easy to learn
  • Data binding, form validation, i18n... all out of the box
							

Hello {{yourName}}!

Twitter Bootstrap

Great CSS/JavaScript framework for responsive Web apps

  • CSS and HTML elements for all common usages
  • Tons of JavaScript components: menus, navbars, drop-down boxes, alerts...
							
Hello, world!

Server-side technologies

Maven, Spring, Spring MVC REST, Spring Data JPA

Maven

The most popular Java build tool

  • Well-known, pre-defined directories and goals
  • Integration with major IDEs
  • Great plugin ecosystem, including Spring Boot and Yeoman
							
mvn spring-boot:run
							
						

Spring Boot

Spring is the de-facto standard for Java apps

  • IoC, AOP and abstractions to ease application coding
  • Fast and lightweight, and extremely powerful when needed
  • Out-of-the-box configuration by Spring Boot
							
@Service
@Transactional
public class UserService {

    @Inject
    private UserRepository userRepository;

}
							
						

Liquibase

Database updates made easy

  • Handles updating a database schema
  • Works great with Spring and JPA
  • Needs a good understanding of databases and ORM

JPA

The standard ORM solution for Java

  • Hibernate is used underneath
  • Very complete, impressive set of features
  • Still complex to understand for newbies!
							
@Entity
public class User implements Serializable {

    @Id
    private String login;

}
							
						

Spring Data JPA

Adds extra syntaxic sugar on top of JPA

  • Generate you JPA repositories automatically
  • Removes a lot of boilerplate code
							
public interface PersistenceAuditEventRepository extends JpaRepository<PersistentAuditEvent, String> {

    List<PersistentAuditEvent>
        findByPrincipalAndAuditEventDateGreaterThan(String principal, LocalDateTime after);

}
							
						

Caching

Caching is king for performance

  • Ehcache is the most widely used solution
  • HazelCast is a great alternative, with clustering support!
  • 2nd level cache or Spring Caching abstraction
  • 							
    @Entity
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    public class User implements Serializable {
    
    }
    							
    						

Spring MVC REST

The best REST framework in Java

  • Complete, high-performance REST solution
  • Great Spring support, great testing support
							
@RestController
public class AccountResource {
    @RequestMapping(value = "/app/rest/account",
            method = RequestMethod.POST)
    public void saveAccount(@RequestBody UserDTO userDTO) {
        userService.updateUserInformation(userDTO);
    }
}
							
						

Thymeleaf

Server-side templates

  • Used when a Single Web Page application isn't enough
  • Replaces JSPs and JSTLs, which are outdated and deprecated
  • Great templates for Web designers
							

Hello, world

Monitoring

Ready for production with Metrics

  • Formerly Yammer Metrics
  • Monitors the JVM, app server, Spring beans, cache, and more!
  • JMX or Graphite reporting
							
@Timed
public void saveAccount(@RequestBody UserDTO userDTO) {
    userService.updateUserInformation(userDTO);
}
							
						

Meet JHipster

Why all the hype?

You said hype?


At the time of this writing (09/2014), the project is 11 months old:

  • We have 855 Github stars and 52 contributors
  • We are the 3rd most popular Yeoman generator
  • We have 110K page views this month
  • We've been featured on Websites everywhere (Infoworld, SD Times, JavaWorld, Reddit...)
  • And it's growing rapidly

Why?

We've seen lots of cool technologies

  • Can Grunt and Maven be friends?
  • Can AngularJS and Spring MVC REST be friends?
  • We can guarantee you that having everything working together smoothly, with security, caching and monitoring, isn't easy...

JHipster makes everything just work together

  • JHipster creates a complete working application, with all those technologies
  • Everthing just works out-of-the-box
  • You have your Yeoman workflow working great with your Maven goals!

But wait, there's more!

  • "entity" sub-generator to generate a complete JPA entity, from database to AngularJS
  • "service" sub-generator to generate a Spring business service
  • Great support for Spring Security: Ajax endpoints, secured remember-me, audits...
  • Great monitoring screen using Metrics

Production-ready

  • Specific Spring profile with GZipping and HTTP caching headers
  • JavaScript & CSS optimization and minification by Grunt
  • Executable or standard WAR file, with monitoring enabled

Let's build our first app

10 minutes tutorial

Install Yeoman

							
npm install -g yo
npm install -g generator-jhipster
							
						

Create an application

							
yo jhipster
mvn spring-boot:run
							
						

Client-side live reload

Live reload of your client-side code (HTML, CSS, JavaScript) works thanks to Grunt. Edit any file and your browser will refresh automatically:

							
grunt server
							
						

Add an entity

							
yo jhipster:entity foo
							
						

Run in production

							
mvn -Pprod package
cd target/
java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod
							
						

Thank you for your attention

http://jhipster.github.io