1. 程式人生 > >SpringCloud踩坑實戰筆記(入門篇)

SpringCloud踩坑實戰筆記(入門篇)

前言

本週投入了不少的精力著重研究了springCloud相關的基礎知識,把網上的相關博文,資料翻了一遍,搭建出了第一個SpringCould的Demo叢集,把SrpingCould的入門坑踩了一遍,在這記錄一下,希望大家能少走一些彎路。

SpringCould介紹

Spring Cloud為開發人員提供了快速構建分散式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智慧路由,微代理,控制匯流排)。簡單來說,SpringCloud為開發人員提供了一系列貼有Spring品牌的適合於微服務應用開發的服務元件。
本文涉及到的主要內容如下圖所示。
這裡寫圖片描述

Demo架構

這裡寫圖片描述

主要內容

準備工作

建立開發環境,我們一共需要5個工程來完成Demo的搭建,開發環境是maven,jdk8,intellij。
目錄結構如下圖所示,採用maven約定的結構。
這裡寫圖片描述

服務註冊與發現(Spring Eureka)

demo-eureka工程
DemoApplication.java


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }

application.properties
ps這個配置不可用於生產環境,缺乏優化

server.port=8181#埠
spring.application.name=mmb-eureka-server#服務名稱
eureka.client.register
-with-eureka=false#註冊自己,用於叢集形式 eureka.client.fetch-registry=false#若為true的話會報錯

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

負載均衡和連線模板(Spring Ribbon&Feign)

DemoClient2Application.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class DemoClient2Application {

    public static void main(String[] args) {
        SpringApplication.run(DemoClient2Application.class, args);
    }
}

DemoController.java

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@RestController
public class DemoController {

    @Autowired
    private WordFeignClient wordFeignClient;

    @RequestMapping("/abc")
    public String getSentence() {
        return wordFeignClient.getWord() + wordFeignClient.getWord();
    }
}

WordFeignClient.java

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by zhaoenwei on 2017/7/1.
 */
@FeignClient("mmb-eureka-subject")
public interface WordFeignClient {
    @RequestMapping(value = "/", method = RequestMethod.GET)
    String getWord();

}

application.properties

eureka.client.service-url.defaultZone=http://localhost:8181/eureka
server.port= 8182
spring.application.name=mmb-eureka-client2
eureka.instance.prefer-ip-address=true
mmb-eureka-subject.ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RandomRule

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo-client2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo-client2</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.6.1</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.6.1</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

閘道器(Spring Zuul)

ZuulDemoApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
        import org.springframework.cloud.client.SpringCloudApplication;
        import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
        import org.springframework.context.annotation.Bean;

@SpringCloudApplication
@EnableZuulProxy

public class ZuulDemoApplication {
    @Bean
    public SimpleFilter simpleFilter() {
        return new SimpleFilter();
    }

    public static void main(String[] args) {
        SpringApplication.run(ZuulDemoApplication.class, args);
    }
}

SimpleFilter.java

package com.example.demo;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by zhaoenwei on 2017/6/30.
 */
public class SimpleFilter extends ZuulFilter {

    private static Logger log = LoggerFactory.getLogger(SimpleFilter.class);

    @Override
    public String filterType() {
        return "pre";
    }

    @Override
    public int filterOrder() {
        return 1;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        RequestContext ctx = RequestContext.getCurrentContext();
        HttpServletRequest request = ctx.getRequest();
        Map<String,String[]> map=request.getParameterMap();
        JSONObject jsonMap= JSONObject.fromObject(map);

        log.info(String.format("%s request to %s ZEW==>params:%s", request.getMethod(), request.getRequestURL().toString(),jsonMap.toString()));

        return null;
    }

}

application.properties

#path的url是被替換掉的也示例
#zuulIP:zuulPort/sentence2/abc->serviceIP:servicePort/abc
zuul.routes.sentence.path=/sentence2/**
zuul.routes.sentence.serviceId=mmb-eureka-client2
  #zuul.routes.sentence.url=http://localhost:8182/sentence
spring.application.name=mmb-zuul-server
#下面那個引數是去掉zuul-prefix引數產生的字首的,跟path一毛錢關係都沒有

zuul.strip-prefix=false

server.port=8081
eureka.client.service-url.defaultZone=http://localhost:8181/eureka

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>zuul-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>zuul-demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

配置中心與訊息匯流排(Srping Config & Bus)

該配置中心設定是支援在git的統一配置管理,並支援rabbitmq的訊息傳播。也就是說該服務需要rabbitmq的環境。

配置中心

DemoConfigApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
public class DemoConfigApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoConfigApplication.class, args);
    }
}

application.properties

server.port=8888
spring.application.name=config-server
eureka.client.service-url.defaultZone=http://localhost:8181/eureka
eureka.instance.prefer-ip-address=true

bootstrap.properties

spring.cloud.config.server.git.uri=https://github.com/zhaoenweiex/config-repo.git
management.security.enabled=false
spring.cloud.config.server.git.basedir=target/config
spring.cloud.config.server.git.search-paths= configclient
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo-config</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo-config</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

配置客戶端

DemoConfigApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient

public class DemoClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoClientApplication.class, args);
    }
}

DemoController.java

package com.example.demo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.Inet4Address;
import java.net.UnknownHostException;

/**
 * Created by zhaoenwei on 2017/6/29.
 */
@RefreshScope
@RestController
public class DemoController {
    private static long timeStample=System.currentTimeMillis();
//   @Autowired
//   private ConstantProperties constantProperties;

    //從config server拿到的配置資料
    @Value("${words}")
    private String wordsStr;
    @RequestMapping("/")
    public  String getWord() {
        String[] wordArray = wordsStr.split(",");
        String address= null;
        try {
            address = Inet4Address.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        int i = (int)Math.round(Math.random() * (wordArray.length - 1));
            return wordArray[i]+timeStample+ address;
    }
}

application.properties

eureka.client.service-url.defaultZone=http://192.168.31.238:8181/eureka
server.port= ${PORT:${SERVER_PORT:0}}
spring.application.name=mmb-eureka-subject
eureka.instance.prefer-ip-address=true
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.profile=dev
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo-client</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo-client</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <
            
           

相關推薦

SpringCloud實戰筆記(入門)

前言 本週投入了不少的精力著重研究了springCloud相關的基礎知識,把網上的相關博文,資料翻了一遍,搭建出了第一個SpringCould的Demo叢集,把SrpingCould的入門坑踩了一遍,在這記錄一下,希望大家能少走一些彎路。 SpringCou

SpringCloud入門到進階(七)——實戰之Zuul服務呼叫失敗與檔案上傳問題

內容   上一節搭建了具有服務熔斷、負載均衡的微服務架構1.0 ,但是在通過路由呼叫微服務時出現了一些直接呼叫微服務沒有的問題,這也是筆者專案中遇到的真實問題。本文查閱了官方文件等資料,介紹該問題的解決方法。 版本   IDE:IDEA 2017.2.2 x64   JDK:1.8.0_171   

SpringCloud筆記(四)------- zuul基礎

本文建立在上一篇文章《SpringCloud踩坑筆記(三)-------服務註冊與消費》之上。我們將引入 Spring Cloud Zuul 來做路由的轉發,訪問之前在 Eureka Server 中註冊的服務。           

SpringCloud筆記(三)-------服務註冊與消費

本文建立在上一篇文章《SpringCloud踩坑筆記(二)-------Eureka》之上。啟動 Eureka Server 之後,我們將註冊一個服務到 Eureka Server 中,然後嘗試去消費它。 一、建立服務提供者        

SpringCloud筆記(二)-------Eureka

        Eureka:Spring Cloud 體系中最重要的元件之一,作用是服務的註冊和發現。本文建立在上一篇文章《SpringCloud踩坑筆記(一)-------專案初建》 之上。 一、配置並執行 Eureka

SpringCloud筆記(一)-------專案初建

       本系列文章旨在記錄在學習使用 SpringCloud 的過程中,發現並且解決或者未解決的問題,會以實際的專案搭建為主要過程,不會去闡述 SpringCloud 的定義和基礎概念,這些已經有各路大神很充分的文章了。可以參考 《Spring

springcloud筆記-eureka註冊地址與應用埠不一致

奇葩問題.查了很久沒找到具體問題.一查都是高可用的問題.懵逼.我還沒用到高可用,現在就一個eureka-server最後自己不斷測試找到問題所在,如果你也遇到了,希望不要在這個問題上浪費時間 先看錯誤原因,如果問題不一樣請找別的解決方案,問題描述: 沒改之前的eureka

Vue學習筆記入門——組件的內容分發(slot)

節點 pan 如何 new 深入 接收 span 初始 特殊屬性 本文為轉載,原文:Vue學習筆記入門篇——組件的內容分發(slot) 介紹 為了讓組件可以組合,我們需要一種方式來混合父組件的內容與子組件自己的模板。這個過程被稱為 內容分發 (或 “transclus

Sping Boot入門實戰入門(三):Spring Boot屬性配置

git 測試 add 禁用 rop fix ron org set   該篇為Sping Boot入門到實戰系列入門篇的第三篇。介紹Spring Boot的屬性配置。   傳統的Spring Web應用自定義屬性一般是通過添加一個demo.properties配置文件(

SpringCloud之fein

control enc .post ati 但是 name ssp ida entry 先看報錯 Error starting ApplicationContext. To display the auto-configuration report re-run your

SpringCloud日記 (1) - 使用ip註冊到eureka

pre true key值 pad 取ip fault ins default instance 服務提供者使用主機名註冊到eureka改為使用ip註冊到eureka eureka: client: service-url: defaultZone:

Springcloud記---使用feignclient遠端呼叫服務404

公司專案進行微服務改造,由之前的dubbo改用SpringCloud,微服務之間通過FeignClient進行呼叫,今天在測試的時候,eureka註冊中心有相應的服務,但feignclient就是無法調通,一直報404錯誤,排查過程如下: 一、問題:   服務提供方定義的介面如下: /** *

SpringCloud日記 (2) - zuul開啟https

    springboot專案jar包方式啟動通用     1.證書放入資原始檔夾         2.server 新增 ssl配置           踩坑點: key-store

[vuejs 實戰系列] keep-alive 被 beforeRouteEnter 騙了

大家中秋假期快樂,假期分享一些實戰文章給大家,原創不易,歡迎轉發,一起學習 現在大家基本都在單頁應用裡面使用了 keep-alive 來快取不活動的元件例項,而不是銷燬它們。 用法很簡單:主要是包裹 <keep-alive> ... </k

webservice學習筆記——入門

                 web service入門學習筆記最近要做一個java專案,裡面用到了webservice技術,經過一個多月的磕磕絆絆的摸索,總算如了點門。現將我的學習筆記貼出來,供大家參考。一、實驗環境  win2k + jdk1.6  + javee5.0  + Myeclipse5.1

記錄_八月_1

2018-8-14 星期二 1.部門管理和選單管理中的初始化表格:當前採用的方法為註釋id所在欄位列初始化程式碼 存在問題: 1. id欄位所在列的visible設定不可見無效 2. 將該欄位置於預設單選框{field: 'selectIte

mui學習筆記-入門

mui是用來做什麼的想來大家都已經非常清楚了。在這裡我想說明的是為什麼選mui,我之前也用過light7,f7等前端框架,直到接觸到mui。用一句xx的話來形容就是"斯人若彩虹,遇上方知有",因為它真的很好很強大,這裡說的強大,是說它的配套工具和事件方法以及它的親生父親h5+

airflow分散式部署記錄之安裝

前言 airflow是一款基於python的開源任務流排程系統,但是關於airflow的安裝教程比較匱乏。本人在親自安裝的過程中遇到了很多奇葩的問題,期間也參考了網上的各種資料,在此做下記錄,以備不時之需。 系統環境 作業系統 Centos6.5

【圖形學與遊戲程式設計】開發筆記-入門3:圖形繪製

(本系列文章由pancy12138編寫,轉載請註明出處:http://blog.csdn.net/pancy12138) 這篇文章將會開始講解最基本的圖形繪製方法,也就是說。這一次的教程將為大家展示一個3D圖形是怎麼被一步步的處理並最終顯示出來的。當然,大家應該還記得入門篇

angular2實戰筆記--路由

一:angular路由基礎知識 1.單頁應用SPA: 一個頁面根據路由配置指向不同頁面顯示; 2.理解模組、元件、服務、指令的含義;一個程式必須至少有一個模組和一個元件作為啟動程式入口; 3.ng new project_name --routing  //新增routin