The openFeign remote call returns page 404, the corresponding configuration file does not take effect, and the data source and other problems are excluded

When using the function of putting products on the shelf, when debugging, I found that when the data was sent to ES for storage, the es service could not be called remotely, and the error 404 could not find the interface, as shown in the figure below: At first I thought it was a problem with openFeign. After inspection,
insert image description here
each There are no problems with all kinds of interfaces and annotations, and this 404 is not a problem of not finding the path, but a problem of the service itself. Later, I wrote a simple controller and tested it with postman.
insert image description here

insert image description here

It can be said to be quite strange. I have never encountered this kind of 404. I copied and saved the response result as html, and I was even more surprised when I visited it: what went wrong? I think it may be a conflict between elasticsearch and
insert image description here
springcloud , so I created a new project with nothing but web dependencies, and then added dependencies step by step,
and I could access it normally at the beginning: until I added the common module, I started reporting this error,
**The first step: ** Guess it may be a problem with application.properties, so I replaced it with a yml file,

spring:
  application:
    name: gulimall-test2

server:
  port: 12003

Project startup error: The reason for this problem is that in the pom.xml configuration file, the data connection technology spring-boot-starter-jdbc package is configured. When the configuration file is started, Spring Boot's automatic assembly mechanism will go to configuration Find the connection
insert image description here
configuration information of the relevant database in the file, and throw an exception message if it cannot be exclude = DataSourceAutoConfiguration.classfound It is the dependency that contains druid-spring-boot-starter, which will scan the data source again and increase the exclusion dependency:

@SpringBootApplication(exclude = {
    
    DataSourceAutoConfiguration.class,
        DruidDataSourceAutoConfigure.class})

Successfully start the access:
insert image description here
After changing the configuration file back to properties and starting, the error 404 is still reported, which is really strange

There is also a small episode in the middle. When replacing the configuration file with yml, the yml does not take effect directly, and the port is still 8080. This has been repeated several times, and the bug cannot be reproduced, but the corresponding solution has been found:

完美解决failed to configure a datasource: ‘url‘ attribute is not specified and no em

Reference link:
exclude= {DataSourceAutoConfiguration.class} failure solution

Guess you like

Origin blog.csdn.net/weixin_42260782/article/details/128528775