This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
This video demonstrates the quickest deployment method, and that is to use Gradle to run the `bootRun` task, which comes from the Gradle 'spring-boot' plugin.
Configuring the Embedded Server
When launching a Spring Boot application as a standalone app with an embedded web server, such as Tomcat or Jetty, you can configure various properties, like changing the port or enabling SSL.
Below is an example of enabling SSL on a specified port using a self-signed certificate.
Note that in production, you'd want to have a certificate signed by a third-party so that users don't get browser warnings.
To generate a self-signed certificate, you can use the JDK's keytool
utility as follows:
keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
This will ask you a handful of questions, and upon finishing will generate a file named keystore.p12. Move this file to src/main/resources/keystore.p12.
Then, in application.properties, add the following properties:
server.port: 8443
server.ssl.key-store: classpath:keystore.p12
server.ssl.key-store-password: PASSWORD_USED_WITH_KEYTOOL
server.ssl.keyStoreType: PKCS12
server.ssl.keyAlias: tomcat
Now, when you run the app with ./gradlew bootRun
, you can visit https://localhost:8443 and see your app served via HTTPS. You'll likely see a browser warning since you're using a self-signed certificate, but if you accept the warning, you'll be able to proceed.
Using Github With This Course
You can complete this course by using the code I've made available to you in two ways:
- Use the Github repository I've made available (recommended), or
- Use the project files linked at the bottom of this page
If you choose the recommended option of using the Github repository, it can be found at
https://github.com/treehouse-projects/spring-deploy-weather
To utilize Github with this course, you can download the Github desktop client for your system or use the command line interface provided with Git.
Clone this repository to your machine using the Github desktop client, or using the following command:
git clone git@github.com:treehouse-projects/spring-deploy-weather.git
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up