zoukankan      html  css  js  c++  java
  • 开源项目学习之------AG-Admin环境搭建

    原文地址: https://blog.csdn.net/u011781521/article/details/79056974

    一、框架简介


    AG-Admin是基于Spring Cloud微服务化开发平台,具有统一授权、认证后台管理系统,其中包含具备用户管理、资源权限管理、网关API管理等多个模块,支持多业务系统并行开发,可以作为后端服务的开发脚手架。代码简洁,架构清晰,适合学习和直接项目中使用。核心技术采用Eureka、Fegin、Ribbon、Zuul、Hystrix、JWT Token、Mybatis等主要框架和中间件,前端采用vue-element-admin组件。


    模块说明:



    二、环境搭建


    (一)、导入源码

    首先下载源码到本地,这里下载的2.2版本,最新的有可能有问题。。。




    然后导入到IDEA中,并更新maven依赖,由于项目中使用了lombok,所有需要安装lombok插件,否则你的IDE会报代码缺失。




    项目结构如下




    ├─ace-security
    │  │  
    │  ├─ace-admin----------------管理端服务层
    │  │ 
    │  ├─ace-auth-----------------鉴权中心
    │  │ 
    │  ├─ace-gate-----------------网关负载中心
    │  │ 
    │  ├─ace-center---------------服务注册中心
    │  │   
    │  ├─ace-monitor--------------统一监控中心
    │  │
    │  ├─ace-config---------------统一配置中心
    │  │
    │  ├─ace-api------------------公共服务接口包
    │  │
    │  ├─ace-demo-----------------示例服务代码
    │  │
    │  └─ace-sidebar--------------调用第三方语言



    (二)、安装Redis与rabbitmq和node


    Redis安装可参考我先前的zheng环境搭建篇,node安装也很简单一直下一步下一步,就行了,安装好之后,更换成淘宝源就行了。


    2.1、rabbitmq安装


    Rabbit MQ 是建立在Erlang OTP平台上,所以在安装rabbitMQ之前,需要先安装Erlang ,下载地址为http://www.erlang.org/downloads




    下载好之后,双击进行安装






    安装完成之后创建一个名为ERLANG_HOME的环境变量,其值指向erlang的安装目录




    同时将%ERLANG_HOME%in加入到Path中




    最后打开命令行,输入erl




    如果出现erlang的版本信息就表示erlang语言环境安装成功;


    然后下载Rabbitmq,下载地址为:http://www.rabbitmq.com/download.html








    下载好之后,双击进行安装







    默认安装的RabbitMQ 监听端口是5672,默认用户名:guest,密码:guest。


    2.2、RabbitMQ-Plugins插件安装


    这个插件相当于是一个管理界面,方便我们在浏览器界面查看RabbitMQ各个消息队列以及exchange的工作情况,安装方法是:打开命令行cd进入rabbitmq的sbin目录(我的目录是:C:Program FilesRabbitMQ Server abbitmq_server-3.7.2sbin),输入:


    rabbitmq-plugins enable rabbitmq_management

    命令,稍等会会发现出现plugins安装成功的提示




    然后重启服务,使用命令(此时最后以管理员运行CMD):

    net stop RabbitMQ && net start RabbitMQ



    插件安装完之后,在浏览器输入http://localhost:15672进行验证




    (三)、初始化数据


    分别导入ace-admin/db/init.sql、ace-auth-server/db/init.sql 这两个脚本,导入成功之后,会创建ag_admin和ag_auth两个数据库以及以下一些表:


    表竟然没有中文注释。。。。


    (四)、配置hosts文件


    1. 127.0.0.1 ace-admin
    2. 127.0.0.1 ACE-ADMIN

    修改项目里所有的defaultZone参数,他默认用的是docker,但是我们是这本地开发的,所以改成本地的




    (五)、修改数据库配置文件


    修改ace-admin/src/main/resources/application.yml、ace-gate/src/main/resources/application.yml这两个配置文件中连接数据库的一些信息:




    (六)、按顺序运行main类:CenterBootstrap(ace-center)、ConfigServerBootstrap(ace-config)、AuthBootstrap(ace-auth-server)、AdminBootstrap(ace-admin)、GateBootstrap(ace-gate)







    如果报以下错误MQ超时:

    Caused by: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:368) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:565) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411) at org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:712) at org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint.send(AmqpOutboundEndpoint.java:134) at org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint.handleRequestMessage(AmqpOutboundEndpoint.java:122) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ... 55 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:50) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:799) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:352) ... 63 more

    基本上就是MQ配置有问题。



    如果报以下错误:

    1. Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
    2. 2018-01-14 17:25:15.447 ERROR [bootstrap,,,] 16896 --- [ main] o.s.boot.SpringApplication : Application startup failed
    3. java.lang.IllegalStateException: Failed to execute CommandLineRunner
    4. at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:735)
    5. at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716)
    6. at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703)
    7. at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
    8. at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
    9. at com.github.wxiaoqi.security.admin.AdminBootstrap.main(AdminBootstrap.java:31)
    10. Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: ServiceAuthFeign#getUserPublicKey(String,String) timed-out and no fallback available.
    11. at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:819)
    12. at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:804)
    13. at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140)
    14. at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    15. at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    16. at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1472)
    17. at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1397)
    18. at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    19. at rx.observers.Subscribers$5.onError(Subscribers.java:230)
    20. at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:44)
    21. at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:28)
    22. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    23. at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
    24. at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
    25. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    26. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    27. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    28. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    29. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    30. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    31. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    32. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    33. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    34. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    35. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    36. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    37. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    38. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    39. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    40. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    41. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    42. at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    43. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    44. at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    45. at rx.Observable.unsafeSubscribe(Observable.java:10211)
    46. at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:142)
    47. at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    48. at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    49. at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1$1.run(AbstractCommand.java:1154)
    50. at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:45)
    51. at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41)
    52. at org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixConcurrencyStrategy$HystrixTraceCallable.call(SleuthHystrixConcurrencyStrategy.java:154)
    53. at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:61)
    54. at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.tick(AbstractCommand.java:1159)
    55. at com.netflix.hystrix.util.HystrixTimer$1.run(HystrixTimer.java:99)
    56. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    57. at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    58. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    59. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    60. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    61. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    62. at java.lang.Thread.run(Thread.java:748)
    63. Caused by: java.util.concurrent.TimeoutException: null
    64. at com.netflix.hystrix.AbstractCommand.handleTimeoutViaFallback(AbstractCommand.java:997)
    65. at com.netflix.hystrix.AbstractCommand.access$500(AbstractCommand.java:60)
    66. at com.netflix.hystrix.AbstractCommand$12.call(AbstractCommand.java:610)
    67. at com.netflix.hystrix.AbstractCommand$12.call(AbstractCommand.java:601)
    68. at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140)
    69. ... 16 common frames omitted


    版本问题。。



    全部启动之后




    (七)、启动前端项目


    首先下载UI:https://gitee.com/geek_qi/AG-Admin-v2.0 下载下来之后,解压如下



    然后在该目录下执行以下命令安装依赖,用的是淘宝的源,不清楚地朋友可以百度node更换淘宝源:

    cnpm install



    安装成功之后,会多出一个node_modules目录




    然后启动服务

    1. # 本地开发 开启服务
    2. npm run dev


    他会自动打开浏览器,访问该页面




    然后点击登陆。




    登陆成功之后如上。。


    (八)、部署nginx配置参考


    nginx配置如下:

    1. location / {
    2. # 指向我们打包后上传的前端文件
    3. root /opt/nginx/dist;
    4. index index.html;
    5. }
    6. location /jwt/ {
    7. # 转发请求到后端服务网关
    8. proxy_pass http://127.0.0.1:8765/jwt/;
    9. }
    10. location /api/ {
    11. proxy_pass http://127.0.0.1:8765/api/;
    12. }


    很简单,不会的可参考我前两篇文章的配置。。

  • 相关阅读:
    将MySQL中的数据导入到Solr
    Solr中schema.xml的Field介绍
    Window下Nginx的安装和启动
    Idea中运行shell脚本
    window10 下安装Mysql5.6
    Solr Admin管理界面使用说明
    Solr 整合中文分词器mmseg4j
    Solr安装和使用
    ActiveMQ 安装和使用
    AbstractQueuedSynchronizer源码解析
  • 原文地址:https://www.cnblogs.com/jpfss/p/9917980.html
Copyright © 2011-2022 走看看