開源項目學習之------AG-Admin環境搭建

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

1、框架簡介css


AG-Admin是基於Spring Cloud微服務化開發平臺,具備統一受權、認證後臺管理系統,其中包含具有用戶管理、資源權限管理、網關API管理等多個模塊,支持多業務系統並行開發,能夠做爲後端服務的開發腳手架。代碼簡潔,架構清晰,適合學習和直接項目中使用。核心技術採用Eureka、Fegin、Ribbon、Zuul、Hystrix、JWT Token、Mybatis等主要框架和中間件,前端採用vue-element-admin組件。
html


模塊說明:
前端



2、環境搭建vue


(一)、導入源碼

java

首先下載源碼到本地,這裏下載的2.2版本,最新的有可能有問題。。。node




而後導入到IDEA中,並更新maven依賴,因爲項目中使用了lombok,全部須要安裝lombok插件,不然你的IDE會報代碼缺失。nginx




項目結構以下git




├─ace-security
│  │  
│  ├─ace-admin----------------管理端服務層
│  │ 
│  ├─ace-auth-----------------鑑權中心
│  │ 
│  ├─ace-gate-----------------網關負載中心
│  │ 
│  ├─ace-center---------------服務註冊中心
│  │   
│  ├─ace-monitor--------------統一監控中心
│  │
│  ├─ace-config---------------統一配置中心
│  │
│  ├─ace-api------------------公共服務接口包
│  │
│  ├─ace-demo-----------------示例服務代碼
│  │
│  └─ace-sidebar--------------調用第三方語言
github



(二)、安裝Redis與rabbitmq和nodespring


Redis安裝可參考我先前的zheng環境搭建篇,node安裝也很簡單一直下一步下一步,就好了,安裝好以後,更換成淘寶源就好了。


2.一、rabbitmq安裝


Rabbit MQ 是創建在Erlang OTP平臺上,因此在安裝rabbitMQ以前,須要先安裝Erlang ,下載地址爲http://www.erlang.org/downloads




下載好以後,雙擊進行安裝






安裝完成以後建立一個名爲ERLANG_HOME的環境變量,其值指向erlang的安裝目錄




同時將%ERLANG_HOME%\bin加入到Path中




最後打開命令行,輸入erl




若是出現erlang的版本信息就表示erlang語言環境安裝成功;


而後下載Rabbitmq,下載地址爲:http://www.rabbitmq.com/download.html








下載好以後,雙擊進行安裝







默認安裝的RabbitMQ 監聽端口是5672,默認用戶名:guest,密碼:guest。


2.二、RabbitMQ-Plugins插件安裝


這個插件至關因而一個管理界面,方便咱們在瀏覽器界面查看RabbitMQ各個消息隊列以及exchange的工做狀況,安裝方法是:打開命令行cd進入rabbitmq的sbin目錄(個人目錄是:C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.2\sbin),輸入:


   
   
   
   
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. }
很簡單,不會的可參考我前兩篇文章的配置。。
相關文章
相關標籤/搜索