当我访问 http://localhost:8761/ 或 http://localhost:8761/eureka 时,我收到“Whitelabel Error Page”。
我的应用程序类:
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryServerApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryServerApplication.class, args);
}
}
应用程序属性:
eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
server.port=8761
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.prefer-file-system-access=false
发现服务器模块中的 pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
来自父项目的pom.xml:
<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring-cloud.version>2020.0.4</spring-cloud.version>
</properties>
<modules>
<module>inventory-service</module>
<module>order-service</module>
<module>product-service</module>
<module>discovery-server</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
发现服务器应用程序日志:
2023-09-12T14:25:01.469-03:00 INFO 28640 --- [ main] c.y.g.d.DiscoveryServerApplication : Starting DiscoveryServerApplication using Java 17.0.6 with PID 28640
2023-09-12T14:25:01.472-03:00 INFO 28640 --- [ main] c.y.g.d.DiscoveryServerApplication : No active profile set, falling back to 1 default profile: "default"
2023-09-12T14:25:02.662-03:00 INFO 28640 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2023-09-12T14:25:02.672-03:00 INFO 28640 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-09-12T14:25:02.672-03:00 INFO 28640 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.12]
2023-09-12T14:25:02.777-03:00 INFO 28640 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-09-12T14:25:02.778-03:00 INFO 28640 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1259 ms
2023-09-12T14:25:03.563-03:00 INFO 28640 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-09-12T14:25:03.624-03:00 INFO 28640 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2023-09-12T14:25:03.637-03:00 INFO 28640 --- [ main] c.y.g.d.DiscoveryServerApplication : Started DiscoveryServerApplication in 2.794 seconds (process running for 3.526)
2023-09-12T14:25:03.942-03:00 INFO 28640 --- [2)-192.168.15.7] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-12T14:25:03.943-03:00 INFO 28640 --- [2)-192.168.15.7] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-09-12T14:25:03.944-03:00 INFO 28640 --- [2)-192.168.15.7] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms
我做错了什么?
PS:我使用的是Spring Boot 3.1.3
问题出在
spring-cloud.version
。我将其更改为 <spring-cloud.version>2022.0.4</spring-cloud.version>
并且发现服务器工作了。