DevOps(Development和Operations的组合词)是一组过程、方法与系统的统称,用于促进开发(应用程序/软件工程)、技术运营和质量保障(QA)部门之间的沟通、协作与整合。 它是一种重视“软件开发人员(Dev)”和“IT运维技术人员(Ops)”之间沟通合作的文化、运动或惯例。透过自动化“软件交付”和“架构变更”的流程,来使得构建、测试、发布软件能够更加地快捷、频繁和可靠。 它的出现是由于软件行业日益清晰地认识到:为了按时交付软件产品和服务,开发和运营工作必须紧密合作。 from:https://baike.baidu.com/item/devops/2613029
View DetailsSelenium 是一个用于Web应用程序测试的工具。Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。支持的浏览器包括IE(7, 8, 9, 10, 11),Mozilla Firefox,Safari,Google Chrome,Opera等。这个工具的主要功能包括:测试与浏览器的兼容性——测试你的应用程序看是否能够很好得工作在不同浏览器和操作系统之上。测试系统功能——创建回归测试检验软件功能和用户需求。支持自动录制动作和自动生成 .Net、Java、Perl等不同语言的测试脚本。 from:https://baike.baidu.com/item/selenium/18266
View Details服务治理可以说是微服务架构中最为核心和基础的模块,它主要用来实现各个微服务实例的自动化注册和发现。 Spring Cloud Eureka是Spring Cloud Netflix 微服务套件的一部分,主要负责完成微服务架构中的服务治理功能。 本文通过简单的小例子来分享下如何通过Eureka进行服务治理: 搭建服务注册中心 注册服务提供者 服务发现和消费 ==========我是华丽的分割线======================== 一、搭建服务注册中心 先列出完整目录结构: 搭建过程如下: 创建maven工程:eureka(具体实现略) 修改pom文件,引入依赖
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<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.sam</groupId> <artifactId>eureka</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> </parent> <properties> <javaVersion>1.8</javaVersion> </properties> <!-- 使用dependencyManagement进行版本管理 --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR6</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- 引入eureka server依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> </dependencies> </project> |
创建启动类
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/** * * @EnableEurekaServer * 用来指定该项目为Eureka的服务注册中心 */ @EnableEurekaServer @SpringBootApplication public class EurekaApp { public static void main(String[] args) { SpringApplication.run(EurekaApp.class, args); } } |
配置application.properties文件
|
1 2 3 4 5 6 7 8 9 10 11 12 |
#设置tomcat服务端口号 server.port=1111 #设置服务名称 spring.application.name=eureka-service eureka.instance.hostname=localhost #注册中心不需要注册自己 eureka.client.register-with-eureka=false #注册中心不需要去发现服务 eureka.client.fetch-registry=false #设置服务注册中心的URL eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka |
启动服务并访问,我们会看到这样的画面: 二、注册服务提供者 先列出完整目录结构: 搭建过程如下: 创建maven工程:hello-service(具体实现略) 修改pom文件,引入依赖
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<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.sam</groupId> <artifactId>hello-service</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> </parent> <properties> <javaVersion>1.8</javaVersion> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR6</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- 引入eureka 客户端依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> </dependencies> </project> |
创建启动类
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/*** * * @EnableDiscoveryClient * 让服务使用eureka服务器 * 实现服务注册和发现 * */ @EnableDiscoveryClient @SpringBootApplication public class HelloApp { public static void main(String[] args) { SpringApplication.run(HelloApp.class, args); } } |
创建controller
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@RestController public class HelloController { Logger logger = LoggerFactory.getLogger(HelloController.class); @Autowired DiscoveryClient discoveryClient; @RequestMapping("/hello") public String hello() { ServiceInstance instance = discoveryClient.getLocalServiceInstance(); //打印服务的服务id logger.info("*********" + instance.getServiceId()); return "hello,this is hello-service"; } } |
配置application.properties文件
|
1 2 3 4 5 |
server.port=9090 #设置服务名 spring.application.name=hello-service #设置服务注册中心的URL,本服务要向该服务注册中心注册自己 eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka |
启动并测试 )启动后再hello-service的控制台会有这种字样(xxx代表你的PC名)
|
1 |
Registered instance HELLO-SERVICE/xxx:hello-service:9090 with status UP (replication=false) |
eureka的控制台会打印出如下字样(xxx代表你的PC名)
|
1 |
Registered instance HELLO-SERVICE/xxx:hello-service:9090 with status UP (replication=false) |
)再次访问localhost:1111,会发现有服务注册到注册中心了 三、服务发现和消费 完整目录结构如下: 搭建过程: 创建maven工程(具体实现略) 修改pom文件,引入依赖
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<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.sam</groupId> <artifactId>hello-consumer</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> </parent> <properties> <javaVersion>1.8</javaVersion> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR6</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- 引入eureka 客户端依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <!-- 引入ribbon 依赖 ,用来实现负载均衡,我们这里只是使用,先不作其他介绍--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> </dependency> </dependencies> </project> 这里比hello-service服务提供者,多了ribbon的依赖 |
创建启动类
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@EnableDiscoveryClient @SpringBootApplication public class ConsumerApp { //@Bean 应用在方法上,用来将方法返回值设为为bean @Bean @LoadBalanced //@LoadBalanced实现负载均衡 public RestTemplate restTemplate() { return new RestTemplate(); } public static void main(String[] args) { SpringApplication.run(ConsumerApp.class, args); } } |
|
1 |
这里也要用到@EnableDiscoveryClient, 让服务使用eureka服务器, 实现服务注册和发现 |
创建controller
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
@RestController public class ConsumerController { //这里注入的restTemplate就是在com.sam.ConsumerApp中通过@Bean配置的实例 @Autowired RestTemplate restTemplate; @RequestMapping("/hello-consumer") public String helloConsumer() { //调用hello-service服务,注意这里用的是服务名,而不是具体的ip+port restTemplate.getForObject("http://hello-service/hello", String.class); return "hello consumer finish !!!"; } } |
配置application.properties文件
|
1 2 3 4 5 6 7 |
server.port=9999 spring.application.name=hello-consumer eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka #这里的配置项目和服务提供者hello-service一样 |
启动,测试 )启动eureka。为了展示负责均衡的效果,我们的hello-service启动两个服务,启动两个服务的具体步骤如下 以上是hello-service1的启动步骤,端口号为9090;同样方法设置hello-service2,端口号为9091(具体实现略)。 )启动hello-consumer )再次访问http://localhost:1111/,会发现有2个hello-service服务(端口号一个是9090,一个是9091),1个hello-consume服务 ) 多次访问http://localhost:9999/hello-consumer,会发现hello-service1和hello-service2会轮流被调用(已经实现了负责均衡),可以通过两者的控制台打印内容确认(还记得我们在hello-service的controller中有个loggerlogger.info("*********" + instance.getServiceId());吗?对,就是这个打印) 四、总结 以上实例实现了基本的服务治理: 通过spring-cloud-starter-eureka-server和@EnableEurekaServer实现服务注册中心 通过spring-cloud-starter-eureka和@EnableDiscoveryClient使用并注册到服务注册中心 通过spring-cloud-starter-eureka和@EnableDiscoveryClient使用注册中心并发现服务,通过spring-cloud-starter-ribbon来实现负载均衡消费服务 PS:这里说明下,我用的IDE是Spring Tool Suite,是spring定制版的eclipse,方便我们使用spring进行开发,有兴趣的朋友可以自行百度了解下。 from:https://www.cnblogs.com/sam-uncle/p/8954401.html
View DetailsEureka是Netflix开发的服务发现框架,本身是一个基于REST的服务,主要用于定位运行在AWS域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的。SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务发现功能。 Eureka包含两个组件:Eureka Server和Eureka Client。 Eureka Server提供服务注册服务,各个节点启动后,会在Eureka Server中进行注册,这样EurekaServer中的服务注册表中将会存储所有可用服务节点的信息,服务节点的信息可以在界面中直观的看到。 Eureka Client是一个java客户端,用于简化与Eureka Server的交互,客户端同时也就是一个内置的、使用轮询(round-robin)负载算法的负载均衡器。 在应用启动后,将会向Eureka Server发送心跳,默认周期为30秒,如果Eureka Server在多个心跳周期内没有接收到某个节点的心跳,Eureka Server将会从服务注册表中把这个服务节点移除(默认90秒)。 Eureka Server之间通过复制的方式完成数据的同步,Eureka还提供了客户端缓存机制,即使所有的Eureka Server都挂掉,客户端依然可以利用缓存中的信息消费其他服务的API。综上,Eureka通过心跳检查、客户端缓存等机制,确保了系统的高可用性、灵活性和可伸缩性。 from:https://baike.baidu.com/item/Eureka/22402835?fr=aladdin
View DetailsFor Git 1.x
|
1 |
$ git add -u |
This tells git to automatically stage tracked files — including deleting the previously tracked files. For Git 2.0 To stage your whole working tree:
|
1 |
$ git add -u :/ |
To stage just the current path:
|
1 |
$ git add -u . |
from:https://blog.csdn.net/dahailantian1/article/details/79475644
View Details1. 使用 git checkout 撤销本地修改 即放弃对本地已修改但尚未提交的文件的修改,还原其到未修改前的状态。 注意: 已 add/ commit 的文件不适用个方法,应该用本文提到的第二种方法。 命令如下:
|
1 2 |
git checkout . # 撤销对所有已修改但未提交的文件的修改,但不包括新增的文件 git checkout [filename] # 撤销对指定文件的修改,[filename]为文件名 |
2. 使用 git reset 回退项目版本 可以回退到任意已经提交过的版本。已 add / commit 但未 push 的文件也适用。 命令如下: 1git reset --hard [commit-hashcode] 2# [commit-hashcode]是某个 commit 的哈希值,可以用 git log 查看 因此一般用法是先用 Git log 查看具体commit的哈希值,然后 reset 到那个版本。 说明: 这两个命令都不会对新增文件起作用。因为新增的文件是还未加到 git 的记录里面的,即属于未被 tracked 的状态,所以撤销修改和回退均对其不影响。我们直接手动删除文件就行了。 转自:http://blog.csdn.net/dandelion_drq/article/details/51259831 from:https://www.cnblogs.com/runningdonkey/p/6932437.html
View DetailsApp.js
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import React, { Component } from 'react' import { Platform, StyleSheet, Text, View } from 'react-native' import { createStackNavigator, createAppContainer } from 'react-navigation' import HomeScreen from './pages/HomeScreen' import ProfileScreen from './pages/ProfileScreen.js' const navigator = createStackNavigator({ Home: { screen: HomeScreen }, Profile: { screen: ProfileScreen } }) const App = createAppContainer(navigator) export default App const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF' }, welcome: { fontSize: 20, textAlign: 'center', margin: 10 }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5 } }) |
pages/ProfileScreen
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import React, { Component } from 'react' import { Text, StyleSheet, View } from 'react-native' export default class ProfileScreen extends Component { static navigationOptions = { title: 'ProfileScreen' } render() { return ( <View> <Text> 2 </Text> </View> ) } } const styles = StyleSheet.create({}) |
pages/HomeScreen
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import React, { Component } from 'react' import { Text, StyleSheet, View, Button } from 'react-native' import { createStackNavigator, createAppContainer } from 'react-navigation'; export default class HomeScreen extends Component { static navigationOptions = { title: 'HomeScreen' } render() { return ( <View> <Text> one </Text> <Button title="go to two" onPress={() => this.props.navigation.navigate('Profile')} /> </View> ) } } const styles = StyleSheet.create({}) |
然后报错: undefined is not an object (evaluating ‘RNGestureHandlerModule.State’ 解决办法: npm install npm install --save react-navigation npm install --save react-native-gesture-handler react-native link 参考: https://www.cnblogs.com/wuvkcyan/p/10011012.html https://blog.csdn.net/quhongqiang/article/details/86597694
View DetailsTextInput是一个允许用户输入文本的基础组件。它有一个名为onChangeText的属性,此属性接受一个函数,而此函数会在文本变化时被调用。另外还有一个名为onSubmitEditing的属性,会在文本被提交后(用户按下软键盘上的提交键)调用。 假如我们要实现当用户输入时,实时将其以单词为单位翻译为另一种文字。我们假设这另一种文字来自某个吃货星球,只有一个单词: 🍕。所以"Hello there Bob"将会被翻译为"🍕🍕🍕"。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import React, { Component } from 'react'; import { AppRegistry, Text, TextInput, View } from 'react-native'; export default class PizzaTranslator extends Component { constructor(props) { super(props); this.state = {text: ''}; } render() { return ( <View style={{padding: 10}}> <TextInput style={{height: 40}} placeholder="Type here to translate!" onChangeText={(text) => this.setState({text})} /> <Text style={{padding: 10, fontSize: 42}}> {this.state.text.split(' ').map((word) => word && '🍕').join(' ')} </Text> </View> ); } } |
在上面的例子里,我们把text保存到 state 中,因为它会随着时间变化。 文本输入方面还有很多其他的东西要处理。比如你可能想要在用户输入的时候进行验证,在React 中的受限组件一节中有一些详细的示例(注意 react 中的 onChange 对应的是 rn 中的 onChangeText)。此外你还需要看看TextInput 的文档。 TextInput 可能是天然具有“动态状态”的最简单的组件了。下面我们来看看另一类输入组件,先从如何处理触摸开始学习。 from:https://reactnative.cn/docs/handling-text-input/
View Details我们在 React Native 中使用 flexbox 规则来指定某个组件的子元素的布局。Flexbox 可以在不同屏幕尺寸上提供一致的布局结构。
一般来说,使用flexDirection、alignItems和 justifyContent三个样式属性就已经能满足大多数布局需求。
本文档贡献者:sunnylqm(100.00%) 在 React Native 中,你并不需要学习什么特殊的语法来定义样式。我们仍然是使用 JavaScript 来写样式。所有的核心组件都接受名为style的属性。这些样式名基本上是遵循了 web 上的 CSS 的命名,只是按照 JS 的语法要求使用了驼峰命名法,例如将background-color改为backgroundColor。 style属性可以是一个普通的 JavaScript 对象。这是最简单的用法,因而在示例代码中很常见。你还可以传入一个数组——在数组中位置居后的样式对象比居前的优先级更高,这样你可以间接实现样式的继承。 实际开发中组件的样式会越来越复杂,我们建议使用StyleSheet.create来集中定义组件的样式。比如像下面这样:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class LotsOfStyles extends Component { render() { return ( <View> <Text style={styles.red}>just red</Text> <Text style={styles.bigBlue}>just bigBlue</Text> <Text style={[styles.bigBlue, styles.red]}>bigBlue, then red</Text> <Text style={[styles.red, styles.bigBlue]}>red, then bigBlue</Text> </View> ); } } const styles = StyleSheet.create({ bigBlue: { color: 'blue', fontWeight: 'bold', fontSize: 30, }, red: { color: 'red', }, }); |
常见的做法是按顺序声明和使用style属性,以借鉴 CSS 中的“层叠”做法(即后声明的属性会覆盖先声明的同名属性)。 文本的样式定义请参阅Text 组件的文档。 现在你已经了解如何调整文本样式了,下面我们要学习的是如何控制组件的尺寸。 from:https://reactnative.cn/docs/style/
View Details