Spring_构造注入
依赖注入的第二种注入方式:构造器注入
创建带参数的构造方法,参数类型为注入类的类型
项目要先添加spring支持;
- package com;
- public class Computer {
- private Host host;
- private Display display;
- //public Computer(){}
- public Computer(Host host, Display display) {
- this.host = host;
- this.display = display;
- }
- public void run() {
- System.out.println(host.run() + "; " + display.run());
- }
- /*public void setHost(Host host) {
- this.host = host;
- }
- public void setDisplay(Display display) {
- this.display = display;
- }*/
- }

package com;
public class Computer {
private Host host;
private Display display;
//public Computer(){}
public Computer(Host host, Display display) {
this.host = host;
this.display = display;
}
public void run() {
System.out.println(host.run() + "; " + display.run());
}
/*public void setHost(Host host) {
this.host = host;
}
public void setDisplay(Display display) {
this.display = display;
}*/
}
- package com;
- public class Display {
- public String run(){
- return "我是显示器,我在运行";
- }
- }

package com;
public class Display {
public String run(){
return "我是显示器,我在运行";
}
}
- package com;
- public class Host {
- public String run() {
- return "我是主机,我在运行";
- }
- }

package com;
public class Host {
public String run() {
return "我是主机,我在运行";
}
}
- <?xml version="1.0" encoding="UTF-8"?>
- <beans
- xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
- <bean id="host" class="com.Host"></bean>
- <bean id="display" class="com.Display"></bean>
- <bean id="computer" class="com.Computer">
- <!--要有默认构造方法,和属性的set方法-->
- <!-- <property name="host" ref="host"></property>
- <property name="display" ref="display"></property> -->
- <constructor-arg name="host" ref="host"/>
- <!-- 用另外一种,两种配置 -->
- <constructor-arg index="1">
- <ref bean="display"/>
- </constructor-arg>
- </bean>
- </beans>

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="host" class="com.Host"></bean> <bean id="display" class="com.Display"></bean> <bean id="computer" class="com.Computer"> <!--要有默认构造方法,和属性的set方法--> <!-- <property name="host" ref="host"></property> <property name="display" ref="display"></property> --> <constructor-arg name="host" ref="host"/> <!-- 用另外一种,两种配置 --> <constructor-arg index="1"> <ref bean="display"/> </constructor-arg> </bean> </beans>
TestComputer
- package com;
- import org.junit.Test;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- public class TestComputer {
- @Test
- public void testRun(){
- ApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
- Computer computer = (Computer) ac.getBean("computer");
- computer.run();
- }
- }

package com;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestComputer {
@Test
public void testRun(){
ApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
Computer computer = (Computer) ac.getBean("computer");
computer.run();
}
}
自动装配:Spring可以自动根据属性类型、名称等进行注入 autowire属性可以设置为no、byType或byName byName 一个都没找到,不报错;采用byName方式,将根据属性名称在Spring Bean Factory中找,找到即自动注入,否则,什么都不做 byType 找到一个以上报错; Spring提供了依赖检查功能 default-dependency-check属性 spring3.0以后没有了;
- package com;
- public class Computer {
- private Host host;
- private Display display;
- public Computer(){}
- public Computer(Host host, Display display) {
- this.host = host;
- this.display = display;
- }
- public void run() {
- System.out.println(host.run() + "; " + display.run());
- }
- public void setHost(Host host) {
- this.host = host;
- }
- public void setDisplay(Display display) {
- this.display = display;
- }
- }

package com;
public class Computer {
private Host host;
private Display display;
public Computer(){}
public Computer(Host host, Display display) {
this.host = host;
this.display = display;
}
public void run() {
System.out.println(host.run() + "; " + display.run());
}
public void setHost(Host host) {
this.host = host;
}
public void setDisplay(Display display) {
this.display = display;
}
}
- package com;
- public class Display {
- public String run(){
- return "我是显示器,我在运行";
- }
- }

package com;
public class Display {
public String run(){
return "我是显示器,我在运行";
}
}
- package com;
- public class Host {
- public String run() {
- return "我是主机,我在运行";
- }
- }

package com;
public class Host {
public String run() {
return "我是主机,我在运行";
}
}
- <?xml version="1.0" encoding="UTF-8"?>
- <beans
- xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
- default-autowire="byName"
- >
- <!-- 第一种 :上面的 default-autowire="byName" 全局的,在beans上配置 -->
- <!-- 第二种:autowire="byName" 方式 -->
- <bean id="host" class="com.Host"></bean><!--autowire="byName"名字必须是host -->
- <bean id="display" class="com.Display"></bean>
- <bean id="computer" class="com.Computer" autowire="byName">
- <!-- 第二种:autowire="byType" 方式
- <bean id="host1" class="com.Host"></bean>
- <bean id="display1" class="com.Display"></bean>
- <bean id="computer" class="com.Computer" autowire="byType">
- -->
- <!--使用自动装配 这个不用
- <property name="host" ref="host"></property> -->
- </bean>
- </beans>

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" default-autowire="byName" > <!-- 第一种 :上面的 default-autowire="byName" 全局的,在beans上配置 --> <!-- 第二种:autowire="byName" 方式 --> <bean id="host" class="com.Host"></bean><!--autowire="byName"名字必须是host --> <bean id="display" class="com.Display"></bean> <bean id="computer" class="com.Computer" autowire="byName"> <!-- 第二种:autowire="byType" 方式 <bean id="host1" class="com.Host"></bean> <bean id="display1" class="com.Display"></bean> <bean id="computer" class="com.Computer" autowire="byType"> --> <!--使用自动装配 这个不用 <property name="host" ref="host"></property> --> </bean> </beans>
- package com;
- import org.junit.Test;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- public class TestComputer {
- @Test
- public void testRun(){
- ApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
- Computer computer = (Computer) ac.getBean("computer");
- computer.run();
- }
- }

package com;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestComputer {
@Test
public void testRun(){
ApplicationContext ac =new ClassPathXmlApplicationContext("applicationContext.xml");
Computer computer = (Computer) ac.getBean("computer");
computer.run();
}
}
拆分配置文件: 新建Dao Service Action的配置文件,修改web.xml使用通配符*; 测试类测试 EmployeeServiceTest
拆分配置文件两种方法 1.配制Spring集成时:配制ContextLoadListener的contextConfigLocation属性,配置多个配置文件用,逗号隔开;或者使用通配符 2.在公用配置文件使用<import resource="x.xml"/>方式
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
- ">
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
- </bean>
- <!-- 配置事务管理器 -->
- <bean id="txManage" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <!-- 要被事务管理(支持)的方法 -->
- <tx:advice id="txAdvice" transaction-manager="txManage">
- <tx:attributes >
- <!-- 默认false;propagation="REQUIRED":hibernate4的时候必须要使用 REQUIRED-->
- <tx:method name="get*" read-only="true" propagation="REQUIRED"/>
- <tx:method name="search*" read-only="true" propagation="REQUIRED"/>
- <tx:method name="find*" read-only="true" propagation="REQUIRED"/>
- <tx:method name="query*" read-only="true" propagation="REQUIRED"/>
- <tx:method name="*" rollback-for="DataAccessException" propagation="REQUIRED"/> <!-- 读写 -->
- </tx:attributes>
- </tx:advice>
- <!-- 切到类里面去(事务要加到哪里,一般在业务里面) -->
- <aop:config>
- <!--execution:切面要在哪里切,(* com.jboa.*.*(..)):com.jboa.service下所以的类,所以的方法,所以的返回值,都受到切面的影响 -->
- <aop:pointcut expression="execution(* com.jboa.service.*.*(..))" id="serviceMethods"/>
- <!-- 注释掉,就没事务了 -->
- <aop:advisor pointcut-ref="serviceMethods" advice-ref="txAdvice"/>
- </aop:config>
- <!-- 拆分配置文件:到新建 DaoApplicationContext.xml-->
- <!-- <bean id="accountDao" class="com.jboa.dao.impl.AccountDaoImpl" depends-on="sessionFactory">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <bean id="employeeDao" class="com.jboa.dao.impl.EmployeeDaoImpl" depends-on="sessionFactory">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <bean id="dictionaryDao" class="com.jboa.dao.impl.DictionaryDaoImpl" depends-on="sessionFactory">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean> -->
- <!-- 拆分配置文件:到新建 ServiceApplicationContext.xml-->
- <!-- <bean id="employeeService" class="com.jboa.service.impl.EmployeeServiceImpl">
- <property name="employeeDao" ref="employeeDao"></property>
- </bean>
- <bean id="dictionaryService" class="com.jboa.service.impl.DictionaryServiceImpl">
- <property name="dictionaryDao" ref="dictionaryDao"></property>
- </bean> -->
- <!-- 拆分配置文件:到新建 ActionApplicationContext.xml-->
- <!-- <bean id="employeeAction" class="com.jboa.action.EmployeeAction" scope="prototype">
- <property name="employeeService" ref="employeeService"></property>
- <property name="dictionaryService" ref="dictionaryService"></property>
- </bean> -->
- <!-- 第二种方式 -->
- <!-- <import resource="DaoApplicationContext.xml"/>
- <import resource="ServiceApplicationContext.xml"/>
- <import resource="ActionApplicationContext.xml"/> -->
- </beans>

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<!-- 配置事务管理器 -->
<bean id="txManage" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 要被事务管理(支持)的方法 -->
<tx:advice id="txAdvice" transaction-manager="txManage">
<tx:attributes >
<!-- 默认false;propagation="REQUIRED":hibernate4的时候必须要使用 REQUIRED-->
<tx:method name="get*" read-only="true" propagation="REQUIRED"/>
<tx:method name="search*" read-only="true" propagation="REQUIRED"/>
<tx:method name="find*" read-only="true" propagation="REQUIRED"/>
<tx:method name="query*" read-only="true" propagation="REQUIRED"/>
<tx:method name="*" rollback-for="DataAccessException" propagation="REQUIRED"/> <!-- 读写 -->
</tx:attributes>
</tx:advice>
<!-- 切到类里面去(事务要加到哪里,一般在业务里面) -->
<aop:config>
<!--execution:切面要在哪里切,(* com.jboa.*.*(..)):com.jboa.service下所以的类,所以的方法,所以的返回值,都受到切面的影响 -->
<aop:pointcut expression="execution(* com.jboa.service.*.*(..))" id="serviceMethods"/>
<!-- 注释掉,就没事务了 -->
<aop:advisor pointcut-ref="serviceMethods" advice-ref="txAdvice"/>
</aop:config>
<!-- 拆分配置文件:到新建 DaoApplicationContext.xml-->
<!-- <bean id="accountDao" class="com.jboa.dao.impl.AccountDaoImpl" depends-on="sessionFactory">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="employeeDao" class="com.jboa.dao.impl.EmployeeDaoImpl" depends-on="sessionFactory">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="dictionaryDao" class="com.jboa.dao.impl.DictionaryDaoImpl" depends-on="sessionFactory">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> -->
<!-- 拆分配置文件:到新建 ServiceApplicationContext.xml-->
<!-- <bean id="employeeService" class="com.jboa.service.impl.EmployeeServiceImpl">
<property name="employeeDao" ref="employeeDao"></property>
</bean>
<bean id="dictionaryService" class="com.jboa.service.impl.DictionaryServiceImpl">
<property name="dictionaryDao" ref="dictionaryDao"></property>
</bean> -->
<!-- 拆分配置文件:到新建 ActionApplicationContext.xml-->
<!-- <bean id="employeeAction" class="com.jboa.action.EmployeeAction" scope="prototype">
<property name="employeeService" ref="employeeService"></property>
<property name="dictionaryService" ref="dictionaryService"></property>
</bean> -->
<!-- 第二种方式 -->
<!-- <import resource="DaoApplicationContext.xml"/>
<import resource="ServiceApplicationContext.xml"/>
<import resource="ActionApplicationContext.xml"/> -->
</beans>
web.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
- <display-name></display-name>
- <welcome-file-list>
- <welcome-file>login.jsp</welcome-file>
- </welcome-file-list>
- <!-- 整合Spring -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <!-- 第一种拆分方式 -->
- <param-value>classpath:*ApplicationContext.xml</param-value>
- <!-- 第二种拆分方式 -->
- <!-- <param-value>classpath:DefaultApplicationContext.xml</param-value> -->
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!-- 配置strut2的过滤器 -->
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- </web-app>

<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- 整合Spring --> <context-param> <param-name>contextConfigLocation</param-name> <!-- 第一种拆分方式 --> <param-value>classpath:*ApplicationContext.xml</param-value> <!-- 第二种拆分方式 --> <!-- <param-value>classpath:DefaultApplicationContext.xml</param-value> --> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置strut2的过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
然后执行测试类测试:
- package com.jboa.service;
- import org.junit.Test;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- import com.jboa.model.Department;
- import com.jboa.model.Employee;
- import com.jboa.model.Postion;
- public class EmployeeServiceTest {
- @Test
- public void testAdd() {
- ApplicationContext ac = new ClassPathXmlApplicationContext("/*ApplicationContext.xml");
- EmployeeService employeeService = (EmployeeService) ac.getBean("employeeService");
- Employee employee = new Employee();
- employee.setSn("user111111");
- employee.setPassword("user111111");
- employee.setStatus("1");
- employee.setName("user111111");
- Postion p = new Postion();
- p.setId(2);
- employee.setPostion(p);
- Department d = new Department();
- d.setId(1);
- employee.setDepartment(d);
- employeeService.add(employee);
- }
- }
Spring_构造注入的更多相关文章
- Spring 设值注入 构造注入 p命名空间注入
注入Bean属性---构造注入配置方案 在Spring配置文件中通过<constructor-arg>元素为构造方法传参 注意: 1.一个<constructor-arg>元素 ...
- Ioc和Aop扩展--多种方式实现依赖注入(构造注入,p命名空间注入,集合类型注入,注入null和注入空值)
构造注入 语法: <constructor-arg> <ref bean="bean的id"/> </constructor-arg> 1 ...
- Spring(3.2.3) - Beans(2): 属性注入 & 构造注入
依赖注入是指程序运行过程中们如果需要另外的对象协作(访问它的属性或调用它的方法)时,无须在代码中创建被调用者,而是依赖于外部容器的注入. 属性注入(Setter Injection) 属性注入是指 I ...
- spring 构造注入 异常 Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments
你可能在做项目的时候,需要在项目启动时初始化一个自定义的类,这个类中包含着一个有参的构造方法,这个构造方法中需要传入一些参数. spring提供的这个功能叫“构造注入”, applicationCon ...
- Spring注入值得2种方式:属性注入和构造注入
Spring是一个依赖注入(控制反转)的框架,那么依赖注入(标控制反转)表现在那些地方了? 即:一个类中的属性(其他对象)不再需要手动new或者通过工厂方法进行创建,而是Spring容器在属性被使用的 ...
- Spring接口编程_设值注入和构造注入
说明: UserManagerImp是设值注入,UserManagerImp2是构造注入 接口不注入,也就是在Spring配置文件中没有接口的<bean>,但是定义的时候是用接口 priv ...
- Spring学习(3)---Spring设值注入和构造注入
(一)设值注入就是指要被注入的类中定义有一个setter()方法,并在参数中定义需要注入的对象.简单的看个例子. 建一个User类: package com.ioc; public class Use ...
- 7.28.1 Spring构造注入还是设置注入
1. 构造方法注入代码如下:public UserManagerImpl(UserDao userDao) { ...
- SSM-Spring-04:Spring的DI的构造注入,P命名注入,和集合注入
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- DI和IOC相比,DI更偏向于实现 DI的set方式注入在前面入门案例里有写,所以此处不多啰嗦,直接开搞,先说 ...
随机推荐
- HNU 13073 Ternarian Weights 解题报告
本题大意: 用天平对一物品进行称重,现有重量不同的砝码,砝码的重量分别为:1,3,9,27,..,3^n.(n<20) 天平的右侧放砝码,左侧放物品或物品和砝码,使得左右两边的重量相等. 现有一 ...
- mui中文在线手册及教程文档
http://dev.dcloud.net.cn/mui/ui/index.html#mask http://ask.dcloud.net.cn/question/2403 http://ask.dc ...
- MySQL5.6多实例部署
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://suifu.blog.51cto.com/9167728/1850560 无论是迫 ...
- php Excel文件导入 Spreadsheet_Excel_Reader
刚刚开通博客,希望能够通过博客的形式记录自己的学习与成长,同时也希望能够和路上的同僚们多交流,共同进步 小白 -> 大神 go! go! go!! 先总结一下前几天写的Excel导入吧,希 ...
- VMware虚拟机与宿主无法复制的解决办法
由于工作需要,上网机器使用虚拟机,因此需要经常来回的拷贝文件,而vmware从6.5一直走来到10.0.1,总是有一个问题很让人苦恼---共享粘贴板总是会无故失效.经常实验,发现可以经过以下方法临时解 ...
- 7-1 vim 编辑器
1. vi:visual interface. 1. vim:vi improved 这些都属于全屏编辑器,又是模式化编辑器 vim模式(3种) 编辑模式(命令模式) 输入模式 末行模式 模式转换 编 ...
- Unity游戏开发——自动为动画剪辑添加事件 之 最后几帧的事件不能被调用的问题
最近在做一个根据配置表自动生成动画剪辑clip以及controller的功能.做法是根据配置表配置的动作以及每个动作的关键帧,自动为每个clip添加事件.这样做可以把动画的事件处理在游戏运行之前就计算 ...
- mybatis判断集合为空或者元素个数为零
mybatis判断集合为空或者元素个数为零: <if test="mlhs != null and mlhs.size() != 0"> and t.mlh_name ...
- js动画(四)
终于到了最后了,这里要告一段落了,整了个js运动框架,咳咳咳,好冷 啊啊啊啊啊啊,这天气.妈的,工资怎么也不发,啊,说好的 人与人之间的信任呢?哎,气诶,不到150字啊,又是这个梗..怎么办?说些什么 ...
- 关于在VI中查看BIN文件二进制值不对的问题
通常,我们在vim中,可以使用命令 %!xxd 来查看文件对应的二进制值.但是最近发生了一个事情,查看到的BIN文件二进制值和直接用hexdump打印出来的不一样. 经过检查定位,发现是因为vimrc ...