Create a Spring Boot Application part1
Create a Spring Boot Application
Now, let’s create a spring boot application and go through more details. The following application is created in IntellijIDEA 15 CE. The project is developed based on JDK 1.8 and uses maven 4.
First of all, create a Maven project in your IDEA and configure the file to include all required dependencies in the project. In this tutorial, we use spring-boot-1.3.3-RELEASE to configure the spring boot application. Also, we use webjars libraries to include all necessary js files for Angularjs.
pom.xml
WebJars is simply taking the concept of a JAR and applying it to client-side libraries or resources. For example, the library may be packaged as a JAR and made available to your Spring Boot application. Many WebJars are available through Maven Central with a GroupID for . A complete list is available at webjars.org.
JavaScript package management is not a new concept. In fact, npm and bower are two of the more popular tools, and currently offer solutions to managing JavaScript dependencies. Spring’s Understanding JavaScript Package Managers guide has more information on these. Most JavaScript developers are likely familiar with npm and bower and make use of those in their projects. However, WebJars utilizes Maven’s dependency management model to include JavaScript libraries in a project, making it more accessible to Java developers.
Spring boot application configuration
The class provides a convenient way to bootstrap a Spring boot application that will be started from a method. In many situations you can just delegate to the static method similar to the following class:
WebAppInitializer.java
tags the class as a source of bean definitions for the application context.
tells Spring Boot to start adding beans based on classpath settings, other beans and various property settings.
tells Spring Boot to start adding beans based on classpath settings, other beans and various property settings.
tells Spring to look for other components, configurations and services in the specified package which allows the application to find the MainController.
By default Spring Boot will serve static content from a directory called (or or or ) in the classpath or from the root of the . Here, the static content is under the directory.
A simple Controller
The following class is only a simple controller which is implemented to handle the request to and render the request to .
MainController.java


Comments
Post a Comment