Cannot resolve symbol for EnableEurekaServer in intelliJ. Yes I have the dependency/invalidated+rest

https://stackoverflow.com/questions/49328567/cannot-resolve-symbol-for-enableeurekaserver-in-intellij-yes-i-have-the-depende

 

解决方案:要在pom.xml里面定义引入相应包的版本

2 Answers

active oldest votes

1

Use the dependency with the specific version, current version at the moment of this writing is:

compile('org.springframework.cloud:spring-cloud-netflix-eureka-server:1.4.3.RELEASE')

You can find the latest available version number here.

For Spring Boot projects when you don't specify the dependency version, the special dependency management plug-in is used. For some reason it fails to provide the version for this specific dependency. See the related question.

shareimprove this answer

answered Mar 16 '18 at 20:43

CrazyCoder

291k5353 gold badges680680 silver badges682682 bronze badges

  • Ahhh I see i see! thank you for explaining. Do you mind checking out this image and see if you can figure out why I am getting this error: imgur.com/a/5Dafv – Syn Mar 16 '18 at 21:20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误通常出现在使用 Spring Cloud Netflix Eureka 时没有正确配置注解。可以尝试以下步骤来解决此问题: 1. 确认项目中已添加了 Spring Cloud Eureka 的依赖。 2. 在启动类上添加注解 `@EnableEurekaServer`,如下所示: ```java import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableEurekaServer public class MyEurekaServerApplication { public static void main(String[] args) { SpringApplication.run(MyEurekaServerApplication.class, args); } } ``` 注意:`@EnableEurekaServer` 注解必须添加在 Spring Boot 应用的启动类上。 3. 确认配置文件中已包含 Eureka Server 相关配置,如下所示: ```properties server.port=8761 eureka.instance.hostname=localhost eureka.client.register-with-eureka=false eureka.client.fetch-registry=false ``` 其中,`server.port` 是 Eureka Server 的端口号,`eureka.instance.hostname` 是 Eureka Server 的主机名,`eureka.client.register-with-eureka` 和 `eureka.client.fetch-registry` 分别表示是否向 Eureka Server 注册和是否从 Eureka Server 获取服务信息。 4. 确认 `@EnableEurekaServer` 注解所在的类的包路径在 Spring Boot 应用的扫描范围内,可以在启动类上添加注解 `@ComponentScan`,如下所示: ```java import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @EnableEurekaServer @ComponentScan(basePackages = {"com.example.eureka"}) public class MyEurekaServerApplication { public static void main(String[] args) { SpringApplication.run(MyEurekaServerApplication.class, args); } } ``` 其中,`@ComponentScan` 注解的 `basePackages` 属性指定了需要扫描的包路径。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值