美文网首页
project 1 -automatic system-Spri

project 1 -automatic system-Spri

作者: gyDBD | 来源:发表于2018-04-21 09:19 被阅读0次

    Spring Boot 

    The problem with Spring and Spring MVC is the amount of configuration that is needed. Spring Boot solves this problem through a combination of Auto Configuration and Starter Projects. 

    Spring Boot looks at a) Frameworks available on the CLASSPATH b) Existing configuration for the application. Based on these, Spring Boot provides basic configuration needed to configure the application with these frameworks. This is called Auto Configuration.

    Spring Boot Start Projects?

    Starters are a set of convenient dependency descriptors that you can include in your application.

     Explain more about Starters with an example?

    Spring Boot Start Web.

    If you want to develop a web application or an application to expose restful services, Spring Boot Start Web is the starter to pick. Lets create a quick project with Spring Boot Starter Web using Spring Initializr.

    Dependency for Spring Boot Starter Web

    <dependency>

        <groupId>org.springframework.boot<groupId>

        <artifactId>spring-boot-starter-web<artifactId>

    </dependency>

    Any typical web application would use all these dependencies. Spring Boot Starter Web comes pre packaged with these.

    What are the other Starter Project Options that Spring Boot provides?

    spring-boot-starter-web-services - SOAP Web Services

    spring-boot-starter-web - Web & RESTful applications

    spring-boot-starter-test - Unit testing and Integration Testing

    spring-boot-starter-jdbc - Traditional JDBC

    What is the easiest approach to create a Spring Boot Project?

    Spring Initializr http://start.spring.io/ is great tool to bootstrap your Spring Boot projects.

     Is Spring Initializr the only way to create Spring Boot Projects?

    No.

    Spring Initializr makes it easy to create Spring Boot Projects. But you can setup a maven project and add the right dependencies to start off.

    Here are the important steps:

    In Eclipse, Use File -> New Maven Project to create a new project.

    Add dependencies.

    Add the maven plugins!

    Add the Spring Boot Application class

    What and Why Embedded Servers?

    This idea is the genesis for Embedded Servers.

    When we create an application deployable, we would embed the server (for example, tomcat) inside the deployable.For example, for a Spring Boot Application, you can generate an application jar which contains Embedded Tomcat. You can run a web application as a normal Java application!

    What is the need for Profiles?

    Enterprise application development is complex. You have multiple environments

    Dev

    QA

    Stage

    Production

    You want to have different application configuration in each of the environments.

    Profiles help to have different application configuration for different environments.

    Q : How can you use profiles to configure environment specific configuration with Spring Boot?

    Profile is nothing but a key to identify an environment.

    In this example, we will use two profiles

    dev

    prod

    The default application configuration is present in application.properties. Let’s consider an example.

    application.properties:

    basic.value= true

    basic.message= Dynamic Message

    basic.number= 100

    相关文章

      网友评论

          本文标题:project 1 -automatic system-Spri

          本文链接:https://www.haomeiwen.com/subject/svvtlftx.html