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
In order to deploy our app to an existing application server, we'll need to build a Web Application ARchive (WAR) that let's the server know about our Spring components.
Structure of a WAR File
If you were to use an archive utility to view the contents of a WAR file, here's what you'd see:
weather-0.0.1-SNAPSHOT.war
ββ META-INF
| ββ MANIFEST.MF # empty except for version
ββ WEB-INF
| ββ classes
| ββ api.properties
| ββ application.properties
| ββ com
| ββ teamtreehouse # our root package
| ββ static/ # web app assets
| ββ templates/ # Thymeleaf templates
| ββ jboss-web.xml # context root definition
| ββ lib # JARs for dependencies
Java Platform, EE (Enterprise Edition)
Java EE defines a set of standards (APIs) for developing web and other enterprise applications. A Java EE application server is one that provides implementations of the Java EE APIs. For a look at all the packages, annotations, interfaces, enums, abstract classes and classes of Java EE 7, see the documentation here:
https://docs.oracle.com/javaee/7/api/
Setting the Active Profile(s)
At runtime
You can set the active profile at runtime, for example, when running your app from a JAR. For this option, you'll specify a system property using the -D
option. For example:
java -Dspring.profiles.active=dev -jar build/libs/weather-0.0.1-SNAPSHOT.jar
In Application.java
You can set profiles programmatically using a SpringApplication
object from your apps class that contains the main
method. This class might look as follows:
@EnableAutoConfiguration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setAdditionalProfiles("dev");
app.run(args);
}
}
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