In springboot, there are the following problems when binding the properties in the class with the configuration in the configuration file:
When using @ configurationproperties, the following prompt appears at the top of idea:
Click the prompt to jump to the official document, and then add the following configuration in POM. XML
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
The effect after adding is that when you write the configuration file (YML, properties configuration file), you will be prompted
After the above is finished, @ configurationproperties will report an error below. You can see it according to the prompt
Not registered via @ enableconfigurationproperties or marked as spring component @ Enable configuration properties (person. Class),
After adding, the error is really gone, but in the unit test of springboot, you will see the following error: could not autowire. No beans of ‘person’ type found
Go back to the user-defined bean person, add the annotation @ component and declare to add the component to the container so that it can be used?
“Only if this component is a component in the container can the @ configurationproperties function provided by the container be used.”
Read More:
- [Vue warn]: Do not use built-in or reserved HTML elements as component id: article
- An error is reported in the spring cloud setup. Autowired appears and Eureka cannot be registered
- It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond applicat
- Vue report failed to mount component: template or render function not defined
- [solved] win10 + office2016 error: library not registered, HResult: 0x8002801d
- Solution: Spring no matching editors or conversion strategy found
- ansible Q&A: Failed to connect to the host via ssh: ssh_exchange_identification and Authentication or per
- Unknown custom element: <component> – did you register the component correctly
- java.lang.IllegalArgumentException: Receiver not registered:
- How to solve the “specified service has been marked for deletion” error
- Spring MVC 406 status code / could not find acceptable representation
- RPC with NFS setup error: program not registered
- SqlSession was not registered for synchronization because synchronization is not active
- The Vue parent component uses ref to call the sub component method and reports an error
- Why not manage controller in spring container
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- Error in installing torch vision or pilot on Linux or Jetson nano: the headers or library files could not be found for JPEG
- After node.js is installed, use the instruction node version in vscode to show that it is not an external or internal instruction. The solution is as follows:
- IntelliJ idea class is normal, but error is marked in red and cannot be found
- Spring cloud Alibaba 2020.0.rc1 does not integrate ribbon error reporting unknownhostexception