国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

Spring Boot Reference Guide Memorandum

imccl / 2831人閱讀

此文章為Spring Boot Reference Guide(2.1.5.RELEASE)的備忘錄。
Chapter 8. Introducing Spring Boot

You can use Spring Boot to create a Java application that can be started by using java -jar or more traditional war deployments.

Spring Boot 2.1.5.RELEASE requires:

Java 8 and is compatible up to Java 11(included).

Spring Framework 5.1.6.RELEASE or above

Maven 3.3 or above

Chapter 10. Installing Spring Boot Installation Instruction for the Java Developer (Ways)

Including the appropriate spring-boot-*.jar files on your classpath in the same way as any standard Java library.

Install appropriate Maven, make POM file inheriting from the spring-boot-starter-patent project and declare dependence spring-boot-starter-web. Optionally config Maven plugin to package the project as an executable jar file.



    4.0.0

    com.example
    myproject
    0.0.1-SNAPSHOT

    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.5.RELEASE
    

    
    
        
            org.springframework.boot
            spring-boot-starter-web
        
    

    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

DEPENDENCIES AUTO UPGRATED
SPRING-BOOT-START-PARENT 1

The spring-boot-start-parent provides a dependency-management section so that we can omit version tags for "blessed" dependences. When you upgrade Spring Boot itself, these dependencies are upgraded as well in a consistent way.
With this setup, we can also override individual dependencies by configure as below


    Fowler-SR2

Install the Spring Boot CLI and run spring run app.groovy.

@RestController
class ThisWillActuallyRun {

    @RequestMapping("/")
    String home() {
        "Hello World!"
    }

}

Generate a new project structure by going to https://start.spring.io to shortcut steps.

Using scope=import dependencies as follows to keep the benefit of the dependency management(but not th e plugin management) and override individual dependencies.


    
        
        
            org.springframework.data
            spring-data-releasetrain
            Fowler-SR2
            pom
            import
        
        
            org.springframework.boot
            spring-boot-dependencies
            2.1.5.RELEASE
            pom
            import
        
    
Upgrading from an Early Version of Spring Boot, you may need spring-boot-properties-migrator
Chapter 11. Developing First Spring Boot Application

Create a Maven pom.xml file and complete it, then run mvn package to test the working build.

mvn dependency:tree

src/main/java/Example.java

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;

@RestController
@EnableAutoConfiguration    // Tell Spring Boot to "guess" how you want to configure Spring based on the jar dependences.
public class Example {

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) {
        SpringApplication.run(Example.class, args);
    }

}

Run mvn spring-boot:run to start the application.

Add the spring-boot-maven-plugin to out pom.xml to used to create an executable jar.


    
        
            org.springframework.boot
            spring-boot-maven-plugin
        
    
MAMUAL OPERATIION REQUIRED
SPRING-BOOT-START-PARENT 2

the spring-boot-starter-parent POM includes configuration to bind the package goal. if you do not use the parent POM, you need to declare this configuration yourself. See https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/maven-plugin/usage.html for more detail.

run mvn package to create an executable jar.

run jave -jar target/myproject-0.0.1-SNAPSHOT.jar to launch the application.

You can use jar -tvf to peek inside.
EXAMPLES

some samples can be referenced at https://github.com/spring-projects/spring-boot/tree/v2.1.5.RELEASE/spring-boot-samples

DEPENDENCIES LIST

All the spring modules that can use with Spring Boot, as well as refined third part libraries, can be found at https://github.com/spring-projects/spring-boot/blob/v2.1.5.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml

Chapter 13. Structuring Code Location of Mail Application Class

The @SpringBootApplication annotation is often placed on the main classpath, and it implicitly defines as base "search package" for certain items. Using a root package also allows the component scan to apply only on this project.

SpringBootApplication

@SpringBootApplication == @EnableAutoConfiguration + @ComponentScan + @Configuration

Typical Layout:

com
 +- example
     +- myapplication
         +- Application.java
         |
         +- customer
         |   +- Customer.java
         |   +- CustomerController.java
         |   +- CustomerService.java
         |   +- CustomerRepository.java
         |
         +- order
             +- Order.java
             +- OrderController.java
             +- OrderService.java
             +- OrderRepository.java
Chapter 15. Configuration Class

We generally recommend that the primary source be a single @Configuration class. Usually, the main class is a good candidate as the primary *@Configurations

@Import can be used to import additional configuration classes.

Alternatively, @ComponentScan can be used to automatically pick up all Spring component including @Configuration classes.

@ImportResource can be used to import load XML configurations file(Totally not recommended)

Chapter 16. Auto-configuration

@EnableAutoConfiguration or @SpringBootApplication attempts to automatically configure application based on the jar dependencies. we generally recommend that you add one or the other to your primary @Configuration class only.

--DEBUG SWITCH WHEN START

To find out what auto-configuration is currently being applied.

We can define exclusion both at the annotation level and ny using the property.

Chapter 17. Spring Beans and Dependency Injection

@ComponentsScan in maim class will automatically register @Component, @Service, @Repository, @Controller etc. as Spring Beans

Chapter 20. Developer Tools

    
        org.springframework.boot
        spring-boot-devtools
        true
    
Property Default

Developer tools are automatically disabled when running a fully packages. Applications launched from java -jar or started from a special class loader are considered as fully packages.
If that does not apply to you, try to exclude devtools or set the -Dspring.devtools.restart.enabled=false system property.

devtool properties
Automatic Restart

DevTools relies on the application context’s shutdown hook to close it during a restart. It does not work correctly if you have disabled the shutdown hook (SpringApplication.setRegisterShutdownHook(false)).

RESTART TECHNOLOGY
Two class loader, base and restart. Classes that do not change(for example third part jar) are loaded into base. Classes that are under development are loaded into restart. When restart, throw restart away. Take advantages of already available and populated base class loader.
Generally speaking, any project in IDE is loaded with the restart and any regular .jar file is loaded with base.

spring.devtools.restart.log-condition-evaluation-delta=false

Disable the logging of the report that shows the condition evaluation delta when restart triggered.

spring.devtools.restart.exclude=static/,public/
spring.devtools.restart.additional-exclude
spring.devtools.restart.additional-paths
spring.devtools.restart.enabled(when false, restart class loader still be initiated but does not watch for file change)
(System property)spring.devtools.restart.enabled(completely disable)

public static void main(String[] args) {
    System.setProperty("spring.devtools.restart.enabled", "false");
    SpringApplication.run(MyApp.class, args);
}

spring.devtools.restart.trigger-file
spring.devtools.livereload.enabled

LIVE RELOAD

trigger browser refresh when a resource is changed.[http://livereload.com/extensi...]

Global Settings Remote Application

Can be used in development environment.

Chapter 23 SpringApplication

FailureAnalyzers to handle error occur when failed to start.
If no analyzer was matched, you can use DEBUG mode when launching application to see detail info.

Customizing the Banner

Adding a banner.txt file to class path.

Setting spring.banner.location property to locate an other file(spring.banner.charset).

Add banner.gif .pnf .jpg to class path.

Setting spring.banner.image.location

SpringApplication.setBanner, .org.springFramework.boot.banner interface and printBanner method.

Placeholders can be used.
MANIFEST.MF
spring.main.banner-mode: console, log, off

Customizing SpringApplication Fluent Builder API

https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/api/org/springframework/boot/builder/SpringApplicationBuilder.html

Application Events and Listeners

You often need not use application events, bunt it is handy to know that they exist.

Web Environment

Determine WebApplicationType:

If Spring MVC is present, an AnnotationConfigServletWebServerApplicationContext is used

If Spring MVC is not present and Spring WebFlux is present, an AnnotationConfigReactiveWebServerApplicationContext is used

Otherwise, AnnotationConfigApplicationContext is used

Changed by setWebApplicationType(WebApplicationType). setApplicationContextClass(…?).

Accessing Application Arguments
import org.springframework.boot.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;

@Component
public class MyBean {

    @Autowired
    public MyBean(ApplicationArguments args) {
        boolean debug = args.containsOption("debug");
        List files = args.getNonOptionArgs();
        // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"]
    }

}

Or can be used by @Value annotation

Using Application Runner or CommandLineRunner

Used when you want to run some special code once the SpringApplication has started.

Application Exit Admin Features Chapter 24 Externalized Configuration

Override order

~/.spring-boot-devtools.properties

Command line arguments. java -jar app.jar —ame=“Spring”. disabled by: SpringApplication.setAddCommandLineProperties(false)

SPRING_APPLICATION_JSON.

$ SPRING_APPLICATION_JSON="{"acme":{"name":"test"}}" && java -jar myapp.jar

java -Dspring.application.json="{"name":"test"}" -jar myapp.jar

java -jar myapp.jar --spring.application.json="{"name":"test"}

Java system properties

OS environment variables

application.properties

Name and path can be changed:

java -jar myproject.jar --spring.config.name=myproject.

java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

Search order by default:

file:./config/

file:./

classpath:/config/

classpath:/

Usage: @Value("${name}")

Random Value

my.secret=${random.value}
my.number=${random.int}
my.bignumber=${random.long}
my.uuid=${random.uuid}
my.number.less.than.ten=${random.int(10)}
my.number.in.range=${random.int[1024,65536]}

[To Be Continued]

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/75138.html

相關文章

  • Spring Boot 學習資料收集

    摘要:系列文章更新計劃列表主要對一些中常用的框架進行簡單的介紹及快速上手,外加相關資料的收集更新列表會不定期的加入新的內容以進行擴充,如果你對此感興趣可以站內聯系我。 導讀: 從第一次接觸Spring Boot 至今已經有半年多了,在這期間也瀏覽了許多和Spring Boot 相關的書籍及文章,公司里面的許多項目也一直在使用Spring Boot。關于Spring Boot的一些看法:Spr...

    mmy123456 評論0 收藏0
  • 開發人員常用框架文檔整理及中文翻譯

    摘要:開發人員常用的框架文檔及中文翻譯,包含系列文檔,日志,,,,數據庫,,等最新官方文檔以及對應的中文翻譯。其它如果你有針對此網站好的建議或意見,也歡迎提更多的文檔和更多的文檔版本支持 開發人員常用的框架文檔及中文翻譯,包含 Spring 系列文檔(Spring, Spring Boot, Spring Cloud, Spring Security, Spring Session),日志(...

    BingqiChen 評論0 收藏0
  • 開發人員常用框架文檔整理及中文翻譯

    摘要:開發人員常用的框架文檔及中文翻譯,包含系列文檔,日志,,,,數據庫,,等最新官方文檔以及對應的中文翻譯。其它如果你有針對此網站好的建議或意見,也歡迎提更多的文檔和更多的文檔版本支持 開發人員常用的框架文檔及中文翻譯,包含 Spring 系列文檔(Spring, Spring Boot, Spring Cloud, Spring Security, Spring Session),日志(...

    objc94 評論0 收藏0
  • Spring Boot 2.0 外部化配置介紹

    摘要:可以使用外部化配置來方便在不同環境的運行同樣的程序文件文件環境變量命令行參數內置順序實現了很多按以下順序進行合理的相同屬性的覆蓋目錄下的全局設置屬性,如果激活測試用例上的注解測試用例上的注解。 簡介 在應用中管理配置并不是一個容易的任務,尤其是在應用需要部署到多個環境中時。通常會需要為每個環境提供一個對應的屬性文件,用來配置各自的數據庫連接信息、服務器信息和第三方服務賬號等。通常的應用...

    lmxdawn 評論0 收藏0

發表評論

0條評論

imccl

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<