Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Spring Boot 2.0 Cookbook

You're reading from   Spring Boot 2.0 Cookbook Configure, test, extend, deploy, and monitor your Spring Boot application both outside and inside the cloud

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher
ISBN-13 9781787129825
Length 286 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Antonov Antonov
Author Profile Icon Antonov
Antonov
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Getting Started with Spring Boot FREE CHAPTER 2. Configuring Web Applications 3. Web Framework Behavior Tuning 4. Writing Custom Spring Boot Starters 5. Application Testing 6. Application Packaging and Deployment 7. Health Monitoring and Data Visualization 8. Spring Boot DevTools 9. Spring Cloud 1. Other Books You May Enjoy Index

Launching an application using Gradle


Typically, the very first step of creating any application is to have a basic startable skeleton. As the Spring Boot starter has created the application template for us already, all we have to do is extract the code, build, and execute it. Now let's go to the console and launch the application with Gradle.

How to do it...

Change the location of our directory to where the bookpub.zip archive was extracted from and execute the following command from the command line:

$ ./gradlew clean bootRun

Note

If you don't have gradlew in the directory, then download a version of Gradle from https://gradle.org/downloads or install it via Homebrew by executing brew install gradle. After Gradle is installed, run wrapper in the gradle folder to get the Gradle wrapper files generated. Another way is to invoke $gradleclean bootRun.

The output of the preceding command will be as follows:

...  .   ____          _            __ _ _ /\ / ___'_ __ _ _(_)_ __  __ _    ( ( )___ | '_ | '_| | '_ / _` |     \/  ___)| |_)| | | | | || (_| |  ) ) ) )  '  |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot ::  (v2.0.0.BUILD-SNAPSHOT)2017-12-16 23:18:53.721 : Starting BookPubApplication on mbp with  
    PID 43850 2017-12-16 23:18:53.781 : Refreshing org.springframework.context.
    annotation.Annotatio2017-12-16 23:18:55.544 : Building JPA container 
    EntityManagerFactory for persistence 2017-12-16 23:18:55.565 : HHH000204: Processing 
    PersistenceUnitInfo [name: default  2017-12-16 23:18:55.624 : HHH000412: Hibernate Core  
    {5.2.12.Final}2017-12-16 23:18:55.625 : HHH000206: hibernate.properties not 
    found2017-12-16 23:18:55.627 : HHH000021: Bytecode provider name : 
    javassist2017-12-16 23:18:55.774 : HCANN000001: Hibernate Commons 
    Annotations {5.0.1.Final2017-12-16 23:18:55.850 : HHH000400: Using dialect: 
    org.hibernate.dialect.H2Dialect2017-12-16 23:18:55.902 : HHH000397: Using 
    ASTQueryTranslatorFactory2017-12-16 23:18:56.094 : HHH000227: Running hbm2ddl schema 
    export2017-12-16 23:18:56.096 : HHH000230: Schema export complete2017-12-16 23:18:56.337 : Registering beans for JMX exposure on 
    startup2017-12-16 23:18:56.345 : Started BookPubApplication in 3.024 
    seconds (JVM running...2017-12-16 23:18:56.346 : Closing 
    org.springframework.context.annotation.AnnotationC..2017-12-16 23:18:56.347 : Unregistering JMX-exposed beans on 
    shutdown2017-12-16 23:18:56.349 : Closing JPA EntityManagerFactory for 
    persistence unit 'def...2017-12-16 23:18:56.349 : HHH000227: Running hbm2ddl schema 
    export2017-12-16 23:18:56.350 : HHH000230: Schema export completeBUILD SUCCESSFULTotal time: 52.323 secs

How it works...

As we can see, the application started just fine, but as we didn't add any functionality or configure any services, it existed straight away. From the startup log, however, we do see that the autoconfiguration did take place. Let's take a look at the following lines:

Building JPA container EntityManagerFactory for persistence unit 
    'default'HHH000412: Hibernate Core {5.2.12.Final}HHH000400: Using dialect: org.hibernate.dialect.H2Dialect

This information tells us that, because we added the jdbc and data-jpa starters, the JPA container was created and will use Hibernate 5.2.12.Final to manage the persistence using H2Dialect. This was possible because we had the right classes in the classpath.

You have been reading a chapter from
Spring Boot 2.0 Cookbook - Second Edition
Published in: Feb 2018
Publisher:
ISBN-13: 9781787129825
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime
Visually different images