eureka相关配置

1) 服务客户端实例名称显示IP配置:

eureka.instance.preferIpAddress=true// 实例名称显示IP配置

2) 状态页面和健康监控:

eureka实例的状态页面和健康监控默认为/info/health,这是spring bootactuator提供的默认终端点。当应用不使用默认的上下文(context pathservlet path,比如配置server.servletPath=/test),或者管理zhongduan路径(比如配置management.contextPath=/admin)。 
application.yml
配置文件如下:

eureka:
  instance:
    statusPageUrlPath: ${management.contextPath}/info
    healthCheckUrlPath: ${management.contextPath}/health

3)eureka服务端配置:


Eureka参数配置:

http://www.itnose.net/detail/6719217.html

Eureka常见问题:

http://www.itmuch.com/spring-cloud-sum-eureka/

修改eureka服务端微服务的显示:

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    preferIpAddress: true
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}        # Instance ID设置成IP:端口的形式

4)Spring Cloud心跳监测

http://www.cfanz.cn/index.php?c=article&a=read&id=313846

5)注解@SpringCloudApplication:

@SpringCloudApplication注解,整合了@SpringBootApplication、@EnableDiscoveryClient、@EnableCircuitBreaker

参照网址(ZUUI):

http://blog.csdn.net/pdw2009/article/details/52792957?locationNum=13&fps=1(源码地址:http://git.oschina.net/didispace/SpringBoot-Learning/tree/master/Chapter9-1-5

6)pom.xml配置:

GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java目录结构。
ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。
一般GroupID就是填com.leafive.test这样子。
如下图:
 
 
 
 

注意:pom.xml引入项目中的jar:

<!—引入jsonplugin-0.34.jar -->

       <dependency>

          <groupId>com.googlecode.jsonplugin</groupId> <!--自定义-->

          <artifactId>jsonplugin</artifactId>   <!--自定义-->

          <version>0.34</version><!--自定义-->

          <scope>system</scope><!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->

          <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/jsonplugin-0.34.jar</systemPath><!--项目根目录下的lib文件夹下-->

</dependency>
文件在项目中的位置如下:
 
 

7)log4j配置:

Log4j.properties


Pox.xml:


如果报错,将版本号改成:1.3.5.RELEASE


如果file写成:d:/log/all.log ,则日志保存在D盘log目录下。

参照网址:

http://blog.didispace.com/springbootlog4j/

http://git.oschina.net/didispace/SpringBoot-Learning/commit/10e751a4415cc3563c66502a6bec24482e32416c#diff-2

说明:Springboot 1.4以下版本需要引入log4jspring-boot-starter-log4j

springboot 1.4及以上版本需要引入log4j2spring-boot-starter-log4j2),否则报错,参照网址:

http://412887952-qq-com.iteye.com/blog/2324637


java页面引用如下所示:

import org.apache.logging.log4j.LogManager;

importorg.apache.logging.log4j.Logger;

static Loggerlogger = LogManager.getLogger(LoginController.class.getName());

注意:

如果需要将log4j配置文件放在项目打包的jar包外,需要进行如下操作

 DOMConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.xml");  

或者

  PropertyConfigurator.configure(System.getProperty("user.dir") + File.separ+ "log4j.properties");  

放到项目启动类的mian函数中,以上代码的区别在于DOMConfigurator载入的是log4j.xmlPropertyConfigurator载入的是log4j.properties文件;

配置文件放在jar包同级目录下(项目的根目录下)。

参照网址:http://blog.csdn.net/qq_15237993/article/details/53322765

这样配置后,会发现日志没有写入指定的日子文件中,解决方法


参照网址:

http://chengxinjingying.cn.board.segmentfault.com/q/1010000009021087

猜你喜欢

转载自blog.csdn.net/shunhua19881987/article/details/75336362
今日推荐