eureka核心配置
1.引用jar包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
2.application.yml配置(由于存在很不起眼的错误,所以导致了报错)正确配置文件在文末
server:
port: 8002
#eureka配置
eureka:
instance:
hostname: localhost #eureka 实例名称
client:
register-with-eureka: false #是否向eureka注册中心注册自己
fetch-registry: false #如果为FALSE表示自己为注册中心
service-url: #监控页面 与eureka
defaultZone: http//${eureka.instance.hostname}:${server.port}/eureka/
3.启动类配置
@SpringBootApplication
@EnableEurekaServer //EnableEurekaServer 服务中心启动类
public class SpringCloudEureka_8002 {
public static void main(String[] args) {
SpringApplication.run(SpringCloudEureka_8002.class,args);
}
}
简单贴一下报错代码
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> replica.key [in template "eureka/navbar.ftl" at line 68, column 62]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
配置完成后访问(这是什么鬼?)
后来经过检查发现是配置文件错误
正确的application.yml 配置文件
server:
port: 8002
#eureka配置
eureka:
instance:
hostname: localhost #eureka 实例名称
client:
register-with-eureka: false #是否向eureka注册中心注册自己
fetch-registry: false #如果为FALSE表示自己为注册中心
service-url: #监控页面 与eureka
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
配置完成后正常的访问界面应该是 路径 http://localhost:8002/ 注8002是自己设置的端口号
如果不是配置文件的问题也有人提出是用户名密码错误请参考
除了这两种情况暂时没有发现有其它问题会导致次错误,如果遇到会及时更新