I have compiled all Java-related interview questions and answers into PDF, and bookmarked the table of contents, which is very convenient to read
questions and answers PDF download : https://www.hicxy.com/?p=2645
questions and answers PDF download : https://www.hicxy.com/?p=2645
questions and answers PDF download : https://www.hicxy.com/?p=2645
1. What are the ways to read configuration in Spring Boot?
Spring Boot can pass
- @PropertySource
- @Value
- @Environment,
- @ConfigurationProperties
To bind variables
2. What is the core configuration file of spring boot? What is the difference between bootstrap.properties and application.properties?
Simply doing Spring Boot development may not be easy to encounter the bootstrap.properties configuration file, but when combined with Spring Cloud, this configuration will often be encountered, especially when you need to load some remote configuration files.
Spring boot core two configuration files:
- bootstrap (. yml or. Properties): boostrap is loaded by the parent ApplicationContext, which is loaded prior to applicaton. The configuration takes effect in the boot phase of the application context. Generally speaking, we will use it in Spring Cloud Config or Nacos. And the attributes in boostrap cannot be overwritten;
- application (. yml or. Properties): is loaded by ApplicatonContext and used for automatic configuration of spring boot projects.
3. What is the difference between Spring Boot's JAR and ordinary JAR
1, Spring Boot project finally packaged into the jar is an executable jar, this kind of jar can be directly run through the java -jar xxx.jar command, this kind of jar cannot be used as a normal jar by other projects, even if it is dependent on It is also not possible to use the classes in it.
2. Spring Boot's jar cannot be relied on by other projects, mainly because its structure is different from ordinary jars. Ordinary jar package, the package name is directly after decompression, and our code is in the package. After the executable jar packaged by Spring Boot is decompressed, it is our code in the \BOOT-INF\classes directory, so it cannot be directly Reference. If you have to refer to it, you can add configuration to the pom.xml file and package the Spring Boot project into two jars, one executable and one referenceable.
4. How do we monitor all Spring Boot microservices?
Spring Boot provides monitor endpoints to monitor the metrics of each microservice. These endpoints are useful for obtaining information about applications (such as whether they have been started) and whether their components (such as databases, etc.) are functioning normally. However, one of the main disadvantages or difficulties of using the monitor is that we must open the knowledge points of the application separately to understand its status or health. Imagine a microservice involving 50 applications. The administrator will have to hit the execution terminals of all 50 applications. To help us deal with this situation, we will use the open source project located at. It is built on Spring Boot Actuator, which provides a Web UI that allows us to visualize the metrics of multiple applications.
5. What is the starter in Spring Boot?
First of all, this Starter is not a new technical point, and is basically implemented based on the existing functions of Spring.
First of all, it provides an automated configuration class, generally named XXXAutoConfiguration. In this configuration class, conditional annotations are used to determine whether a configuration takes effect (conditional annotations are inherent in Spring), and then it also provides a series of default configurations , Developers are also allowed to customize the relevant configuration according to the actual situation, and then inject these configuration attributes through type-safe attribute injection, and the newly injected attributes will replace the default attributes. Because of this, many third-party frameworks can be used directly by introducing dependencies. Of course, developers can also customize Starter
For the rest of the problem, you can first think about it for yourself.
In addition, I have sorted out all Java-related interview questions and answers for your reference
questions and answers PDF download : https://www.hicxy.com/?p=2645
questions and answers PDF download : https://www.hicxy.com/?p=2645
questions and answers PDF download : https://www.hicxy.com/?p=2645
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。