发表于: 2019-10-31 19:40:18

1 896


1.完成的事情:

1)今天一整天都在解决问题;

2.遇到的问题:

1)


服务没有注册到注册中心;



无法连接到服务器的端口;


对应服务的application.yml如下:

server:
port: 20862

spring:
application:
name: learning
datasource:
druid:
url: jdbc:mysql://118.126.113.248:3306/academy_amazing?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
username: arthur
password: arthur
driver-class-name: com.mysql.cj.jdbc.Driver
initial-size: 5 # 初始化时建立物理连接的个数
     max-active: 30 # 最大连接池数量
     min-idle: 5 # 最小连接池数量
     max-wait: 60000 # 获取连接时最大等待时间,单位毫秒
   type: com.alibaba.druid.pool.DruidDataSource

eureka:
client:
serviceUrl:
defaultZone: http://localhost:20861/eureka/

mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.jnshu.pojo
configuration:
map-underscore-to-camel-case: true

########## 分页插件 ##########
pagehelper:
helper-dialect: mysql
params: count=countSql
#分页合理化参数,默认值为false。当该参数设置为 true 时,pageNum<=0 时会查询第一页,
 # pageNum>pages(超过总数时),会查询最后一页。默认false 时,直接根据参数进行查询。
 reasonable: true
#支持通过 mapper 接口参数来传递分页参数,默认值false,
 # 分页插件会从查询方法的参数值中,自动根据上面 params 配置的字段中取值,查找到合适的值时就会自动分页。
 support-methods-arguments: true

multipart:
maxFileSize: 5MB

maxRequestSize: 5MB

然后是注册中心的application.yml:

server:
port: 20861

eureka:
instance:
hostname: localhost
client:
#Eureka 服务注册中心将自己作为客户端来注册自己,需要禁止
   register-with-eureka: false
   fetch-registry: false
   service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

spring:
application:
name: eureka-server

代码本地测试结果:

可以看到learning服务成功注册到了注册中心,然后调用learning中的接口,前台公告展示接口:

成功返回结果;

但是在服务器上就是一直都跑不通,试过很多方法,查看服务器开放端口:


我们组的端口号分别为:20861-20866,上面的20861是我后面在服务器中开放的,但是其他几个端口同样的代码一直开放不了,如下:

也搞过firewall命令在防火墙中添加端口,但是对项目运行没有影响,防火墙本身就是关闭状态,跟组内后端成员沟通了一下,发现都遇到了这个问题,本地代码都可以跑通,但是到服务器上跑不了,注册中心一直是空的;

3.明天的计划:

1)寻求师兄的帮助,解决今天的问题;

2)在服务器上把所有代码跑通;


返回列表 返回列表
评论

    分享到