properties

记一次调试串口设备Bug的经历

拈花ヽ惹草 提交于 2020-01-28 23:07:44
最近花了差不多1天的时间在折腾一个Bug,该Bug的表象如下: 这个Bug还特别独特,在开发电脑中无提示,在终端用户那里每次使用软件的时候都报这个。仔细思考了一下最近在源码中新添加的功能,没发现有啥特别明显的问题。于是,根据字面意思的理解是“运行时错误”,所以一开始解决这个问题的思路是将所有应用程序的运行时拷贝至应用程序目录。尝试过之后,依然报这个异常。分析可能跟运行时的动态链接库没有关系。于是,调整解决问题的思路,考虑将工程中新添加的代码进行分割。部分部分的测试新添加的代码到底那里有问题,排查到最后是这个函数内部发生了异常。异常函数的代码如下: void CleanSerialPort() { if(g_hEvent != NULL) { CloseHandle(g_hEvent); g_hEvent = NULL; } if(g_SerialPort.IsOpen()) { COMMPROP properties; memset(&properties, 0, sizeof(properties)); g_SerialPort.GetProperties(); g_SerialPort.ClearWriteBuffer(); g_SerialPort.ClearReadBuffer(); g_SerialPort.Flush(); g_SerialPort.CancelIo()

springboot知识点补充(一)

大兔子大兔子 提交于 2020-01-28 13:43:39
测试配置 @RunWith(SpringRunner.class) @SpringBootTest @Configuration @ActiveProfiles("test") public class ApplicationTests { @Test public void test() { } } 测试类集成此类就可以实现读取测试的配置文件application-test.properties 在application.properties中配置spring.profiles.active=dev,就可以读取application-dev.properties配置文件信息,在application.properties中可以写一些公共配置,dev中写特殊配置 idea热加载工具devtools工具生效 首先加pom <!-- SpringBoot自带热加载开发工具 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> 在idea选项Compiler中把Build project automatically打钩 再快捷键shift+command

ORM实现原理

北城余情 提交于 2020-01-28 12:13:44
1.什么是ORM ORM的全称是Object Relational Mapping,即对象关系映射。它的实现思想就是将关系数据库中表的数据映射成为对象,以对象的形式展现,这样开发人员就可以把对数据库的操作转化为对这些对象的操作。因此它的目的是为了方便开发人员以面向对象的思想来实现对数据库的操作。 2.什么是Hibernate 对于Hibernate的称呼有很多,比如工具、技术、框架以及解决方案等,这些都可以,重要的是大家要知道它的作用。在这里我习惯性称它为框架,它是一种能实现ORM的框架。能实现ORM这个功能的框架有很多,Hibernate可以说是这些框架中最流行、最受开发者关注的,甚至连JBoss公司也把它吸收进来,利用它在自己的项目中实现ORM功能。 3.ORM的实现原理 现在在Java领域大家对Hibernate的讨论很多,比如它的优缺点、如何应用、错误如何解决以及把它和Struts/Spring等框架相结合作为整个系统的解决方案。在这里我想和大家探讨一些更深层次的话题,那就是Hibernate是如何实现ORM的功能?如果让我们自己开发一款实现ORM功能的框架需要怎么做?其实这些问题就是围绕着一个词,那就是“映射”,如果我们知道如何实现这种映射那么我们也能够开发出自己的一款ORM框架。会使用Hibernate的开发人员都知道,在使用它实现ORM功能的时候,主要的文件有:映射类

spring 常用工具包

本小妞迷上赌 提交于 2020-01-28 08:33:00
spring 常用工具包 具体可以参考spring的文档: http://tool.oschina.net/apidocs/apidoc?api=Spring-3.1.1 Object,String,Number相关 public abstract class StringUtils extends Object 去掉最后一个字符: String lang ="java,c,html,"; lang = StringUtils.trimTrailingCharacter(lang,','); //打印出java,c,html 同理,去掉第一个字符可以trimLeadingCharacter方法。 其余方法可以看详细API。 public abstract class NumberUtils extends Object 类型转换 Integer num =NumberUtils.parseNumber("12", Integer.class); 对象拷贝 org.springframework.beans.BeanUtils //拷贝属性: BeanUtils.copyProperties(source, target, ignoreProperties); Resource,File相关 public abstract class FileCopyUtils extends

python: are property fields being cached automatically?

倾然丶 夕夏残阳落幕 提交于 2020-01-28 04:42:25
问题 My question is are the following two pieces of code run the same by the interpreter: class A(object): def __init__(self): self.__x = None @property def x(self): if not self.__x: self.__x = ... #some complicated action return self.__x and the much simpler: class A(object): @property def x(self): return ... #some complicated action I.e., is the interpreter smart enough to cache the property x ? My assumption is that x does not change - finding it is hard , but once you find it once there is no

SpringBoot自动配置原理

送分小仙女□ 提交于 2020-01-27 14:13:47
SpringBoot自动配置原理 配置文件到底能些什么?怎么写? 配置原理 1.自动配置原理 1)、SpringBoot启动的时候加载主配置类,开启了自动配置功能 @EnableAutoConfiguration 2)、@EnableAutoConfiguration作用 利用EnableAutoConfigurationImportSelector给容器中导入一些组件 可以查看selectImports()方法的内容 List<String> configurations getCandidateConfigurations(annotationMetadata, attributes);//获取候选的配置 SpringFactoriesLoader . loadFactoryNames ( ) 扫描所有jar包类路径下 META - INF / spring . factories 把扫描到的这些文件的内容包装成properties对象 从properties中获取到EnableAutoConfiguration . class 类(类名)对应的值,然后把他们添加在容器中 2.将 类路径下 META-INF/spring.factories 里面配置的所有EnableAutoConfiguration的值加入到了容器中 # Auto Configure org

java MVC 设计模式 【dao层】【Properties类】

拈花ヽ惹草 提交于 2020-01-26 21:24:49
DAO(data access object) 什么是DAO层 DAO(Date Access Object) 模型就是写一个类,把访问数据库的代码封装起来,DAO在数据库与业务逻辑(Service)之间,进行数据的访问和操作。 DAO层包括三个部分 DAO接口:定义了一系列操作数据库的方法。 DAO实现类:实现了操作数据库的方法。(对于不同数据库,有不同的实现) DAO工厂类:返回一个DAO实现类对象。 步骤 1、实体域,即操作的对象,例如我们操作的表示user表,那么就需要先写一个User类; 2、DAO模型需要先提供一个DAO接口; 3、然后再提供一个DAO接口的实现类; 4、再编写一个DAO工厂,Service通过工厂来获取DAO实现; Properties类 (Java.util.Properties) properties类的作用 java配置文件中很多变量是经常改变的,为了方便用户的配置,能让用户够脱离程序本身去修改相关的变量设置。就像在Java中,其配置文件常为.properties文件,是以键值对的形式进行参数配置的。xx.properties 为Java 语言常见的配置文件,如数据库的配置jdbc.properties, 系统参数配置 system.properties。 使用properties类读取properties文件 常用的方法

深度Mybatis源码分析——SqlSessionFactoryBuilder(建造者模式),Mapper接口绑定原理(代理模式)

ぐ巨炮叔叔 提交于 2020-01-26 03:52:17
一: 源码分析流程图 二:源码分析开始 public class TestMyBatis { public static void main(String[] args) { try { // 基本mybatis环境 // 1.定义mybatis_config文件地址 String resources = "mybatis_config.xml"; // 2.获取InputStreamReaderIo流 Reader reader = Resources.getResourceAsReader(resources); // 3.获取SqlSessionFactory SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); // 4.获取Session SqlSession sqlSession = sqlSessionFactory.openSession(); // 5.操作Mapper接口 UserMapper mapper = sqlSession.getMapper(UserMapper.class); UserEntity user = mapper.getUser(2); System.out.println(user.getName()); } catch

笔记-迎难而上之Java基础进阶6

一笑奈何 提交于 2020-01-26 03:10:31
import java.io.*; public class InputStreamDemo{ public static void main(String[] args) throws IOException{ //创建输入流对象,创建对象时绑定读取的数据源 FileInputStream fis = new FileInputStream("E:\\study\\demo12\\c.txt"); //创建byte[] 数组,让他一次性读取多个字节 byte[] bytes = new byte[1024]; int len=0; //用len来接收读取到的有效字节 //因为文件中有5个字节,所以把五个字节传递给len while((len=fis.read(bytes))!=-1){ //String的构造方法,可以把字节数组变成字符串 System.out.println(new String(bytes)); } fis.close(); } } 文件复制 package demo16; import java.io.*; public class CopyDemo{ public static void main(String[] args) throws IOException{ //创建FileInputStream对象,需要指定读取的数据源文件的位置

GAE - Getter without Setter - How to prevent client from writing a given property? How to prevent client from modifying the object ID?

折月煮酒 提交于 2020-01-25 10:37:06
问题 I am writing against Google App Engine using Java and Android Studio. Tools, Install Client Libraries creates a model for the frontend from backend classes. This works well. Now, I have realized that getters and setters are always generated for the client as part of the class model, or at least whenever I use a getter, a setter is auto-generated for the same property. I understand that REST needs to have getters and setters exposed to serialize and deserialize on both sides. But what happens