错误信息就不贴了,8080端口占用,SpringBoot启动失败
做微服务练习写到 Zuul网关模块时,从码云获取端口号,运行时报错8080,多次反复检查发现两个问题
1.注解错误
-
ConfigServer项目中的启动类的注解使用错误,不能使用@EnableEurekaClient
-
应该使用@EnableConfigServer
ConfigServerApp:
package cn.shop.cloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
//@EnableEurekaClient 不能使用这个,会报8080
@EnableConfigServer
public class ConfigServerApp {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApp.class,args);
}
}
2.依赖错误
- Zull网关模块导入config依赖时,应该使用client
- 如果使用server也会报8080端口错误
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>