当前位置: 首页 > 编程日记 > 正文

Java - 框架之 SpringBoot 攻略day01

Spring-Boot 攻略 day01

spring-boot


一. 基本配置加运行

1. 导入配置文件(pom.xml 文件中)

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>1.5.9.RELEASE</version>
  5. </parent>
  6. <dependencies>
  7. <dependency>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-web</artifactId>
  10. </dependency>
  11. </dependencies>

2. Application.java

  1. @SpringBootApplication
  2. publicclassHelloApplication{
  3. publicstaticvoid main(String[] args){
  4. SpringApplication.run(HelloApplication.class, args);
  5. }
  6. }

3. Controller.java

  1. /*
  2. @RestController 可以代替 @ResponseBody 和 @Controller
  3. */
  4. @ResponseBody
  5. @Controller
  6. publicclass h1Controller {
  7. @RequestMapping("/hello")
  8. publicString t1(){
  9. return"Hello!";
  10. }
  11. }

4. 直接运行 Application 中的代码,页面访问 http://localhost:8080/hello 就会看到 Hello!。

5. 打包 jar 包,在 pom.xml 配置文件中添加:

  1. <!-- 这个插件,可以将应用打包成一个可执行的jar包;-->
  2. <build>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.springframework.boot</groupId>
  6. <artifactId>spring-boot-maven-plugin</artifactId>
  7. </plugin>
  8. </plugins>
  9. </build>

6.运行:

java -jar jar包名

二. SpringBoot( pom.xml )文件讲解

1. 依赖包:

都存放在 pom.xml 文件 -> spring-boot-starter-parent -> spring-boot-dependedcies 中

2. 启动器

spring-boot-starter: Spring-Boot 场景启动器。
比如上面的 **spring-boot-starter-web**就帮我们导入了有关web项目的启动器, 所以需要什么场景的starter(启动器),只需要导入相关依赖即可。
  1. <artifactId>spring-boot-starter-web</artifactId>

三. 主程序(主入口)类

1. 注解

@SpringBootApplication :标注在某个类上说明这个类是 SpringBoot 的主配置类,SpringBoot 可以运行这个类的 main 方法来启动服务。

  1. @SpringBootApplication
  2. publicclassHelloApplication{
  3. publicstaticvoid main(String[] args){
  4. SpringApplication.run(HelloApplication.class, args);
  5. }
  6. }

@SpringBootConfiguration :Spring Boot的配置类;

@Configuration :配置类标注这个注解(配置文件;配置类也是容器中的一个组件;@Component)

@EnableAutoConfiguration :开启自动配置功能;

@AutoConfigurationPackage :自动配置包;

@Import(EnableAutoConfigurationImportSelector.class) : 给容器中导入组件;

四. 使用 Spring Initializer 快速创建 Spring Boot 项目

1. 创建 Spring Initializer 项目,并选择需要使用的模块。

2. resources 文件夹中目录结构

  • static : 静态资源
  • templates :模板页面
  • application.properties : SpringBoot 应用的配置文件

五. 配置文件(两者都可配置,写法不同)

1. application.properties

  • 写法:
  1. server.port=8081

2. application.yml (默认没有,需手动创建到 resources 文件下)

  • 写法
  1. server:
  2. port:8081

3. YMAL 基本语法

  • 以空格缩进
  1. server:
  2. port:8081
  • 值的写法

    • 字面量:k: v 的方式来写(注意有个空格在:的后面)

      "" :双引号不会转义特殊字符
      '' : 单引号会转移特殊字符(转义为字符串)

  • 对象,Map 写法

    1. k: v 与上面写法一致

      1. server:
      2. port:8081
    2. 行内表示:

      1. server:{port:8081}
  • 数组 (List, Set)

  1. Person:
  2. - p1
  3. - p2
  4. - p3

4. 配置文件的注入

注意:这个配置顺序要写在单元测试配置之前

  1. <!--导入配置文件处理器,配置文件进行绑定就会有提示-->
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-configuration-processo</artifactId>
  5. <optional>true</optional>
  6. </dependency>

一. yaml 配置

  • application.yml
  1. lastname:张三
  2. age:11
  3. isBoy:true
  4. Date:2019/4/19
  5. maps:{k1: v1, k2:59}
  6. lists:
  7. - li1
  8. - li2
  9. dog:
  10. name:黑狗
  11. age:1
  • Person.java
  1. /*
  2. * 将配置文件中配置的每一个属性值,映射到这个组件中
  3. * @ConfigurationProperties:告诉 SpringBoot 将当前类中的所有属性与 配置文件中的配置进行帮定
  4. * prefix = "person" : 配置文件中哪个下面的所有属性进行映射
  5. *
  6. * 只有这个组件是容器中的组件,才能提供 @ConfigurationProperties 中的功能,也就是需要加上:@Component
  7. * */
  8. @Component
  9. @ConfigurationProperties(prefix ="person")
  10. publicclassPerson{
  11. privateString lastName;
  12. privateInteger age;
  13. privateBoolean isBoy;
  14. privateDate birthday;
  15. privateMap<Object,Object> maps;
  16. privateList<Object> lists;
  17. privateDog dog;
  18. }
  • Dog.java
  1. publicclassDog{
  2. privateString name;
  3. privateInteger age;
  4. }
  • Test 单元测试
  1. @Autowired
  2. Person person;
  3. @Test
  4. publicvoid contextLoads(){
  5. System.out.println(person);
  6. }

二. properties 配置 ( application.properties )

注意:使用这个配置会有编码问题,解决如下( idea ):

settings -> File Encodings 配置下:

Default encoding for properties files: 设置为 UTF-8
勾选:Transparent native-to-ascii conversion 这个选项

  • application.properties 文件
  1. # 配置 Person 的值
  2. person.last-name=张三
  3. person.age=11
  4. person.birthday=2019/4/19
  5. person.isBoy=true
  6. person.maps.k1=v1
  7. person.maps.k2=59
  8. person.lists=p1,p2,p3
  9. person.dog.name=大黑狗
  10. person.dog.age=2
  • 剩余配置如上

三. @ConfigurationProperties 与 @Value

比较@ConfigurationProperties@Value
功能批量注入配置文件中的属性一个个指定
松散绑定(松散语法)支持不支持
SpEL不支持支持
JSR303数据校验支持不支持
复杂类型封装支持不支持
  • 松散绑定 :如果遇到 last-name 可以写成 lastName,也就是带有 - 或 _ 的后一个字母可用大写
  • SpEL : 语法解析,如 ${1*19} , @Value 就可以解析
  • JSR303数据校验 : 内置的 @Eamil 等可以进行数据的校验,详细请看下文
  • 复杂类型封装 :如 Map 等复杂类型 @Value 是无法解析的(List可以解析),会报错
  1. @Component
  2. //@ConfigurationProperties(prefix = "person")
  3. @Validated
  4. publicclassPerson{
  5. // @Value("${person.last-name}")
  6. @Email// 这里 lastName 必须是邮箱格式
  7. privateString lastName;
  8. @Value("#{1*10}")// 可进行逻辑操作
  9. privateInteger age;
  10. privateBoolean isBoy;
  11. privateDate birthday;
  12. privateMap<Object,Object> maps;
  13. privateList<Object> lists;
  14. privateDog dog;
  15. }

四. @PropertySource & @ImportResource & @Bean

@PropertySource:加载指定的配置文件;

  1. /**
  2. *
  3. * @PropertySource : 可以指定到去哪个文件加载配置
  4. */
  5. @PropertySource(value ={"classpath:person.properties"})
  6. @Component
  7. @ConfigurationProperties(prefix ="person")
  8. //@Validated
  9. publicclassPerson{
  10. /**
  11. * <bean class="Person">
  12. * <property name="lastName" value="字面量/${key}从环境变量、配置文件中获取值/#{SpEL}"></property>
  13. * <bean/>
  14. */
  15. //lastName必须是邮箱格式
  16. // @Email
  17. //@Value("${person.last-name}")
  18. privateString lastName;
  19. //@Value("#{11*2}")
  20. privateInteger age;
  21. //@Value("true")
  22. privateBoolean boss;
  23. }

@ImportResource:导入Spring的配置文件,让配置文件里面的内容生效;

Spring Boot里面没有Spring的配置文件,我们自己编写的配置文件,也不能自动识别;

想让Spring的配置文件生效,加载进来;@ImportResource标注在一个配置类上

  1. @ImportResource(locations ={"classpath:beans.xml"})
  2. 导入Spring的配置文件让其生效

使用XML文件加载配置(beans.xml)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beansxmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5. <beanid="helloService"class="com.atguigu.springboot.service.HelloService"></bean>
  6. </beans>

SpringBoot推荐给容器中添加组件的方式:使用全注解

1、配置类@Configuration------>Spring配置文件

2、使用@Bean给容器中添加组件

  • Service.java
  1. // @Configuration :指明当前类为配置类,用来替代 Spring 配置文件
  2. @Configuration
  3. publicclassMyAppConfig{
  4. // @Bean :将方法的返回值添加到容器中,容器中这个组件的默认id就是方法名
  5. @Bean
  6. publicHelloService helloService(){
  7. returnnewHelloService();
  8. }
  9. }
  • 单元测试类
  1. @Autowired
  2. ApplicationContext ioc;
  3. @Test
  4. publicvoid testHelloService(){
  5. System.out.println("执行配置文件...");
  6. boolean b = ioc.containsBean("helloService");
  7. System.out.println(b);
  8. }

五. 配置文件占位符

1、随机数

  1. ${random.value}、${random.int}、${random.long}
  2. ${random.int(10)}、${random.int[1024,65536]}

2、占位符获取之前配置的值,如果没有可以是用:指定默认值

  1. person.last-name=张三${random.uuid}
  2. person.age=${random.int}
  3. person.birth=2017/12/15
  4. person.boss=false
  5. person.maps.k1=v1
  6. person.maps.k2=14
  7. person.lists=a,b,c
  8. person.dog.name=${person.hello:hello}_dog
  9. person.dog.age=15

六. Profile

1、多Profile文件

我们在主配置文件编写的时候,文件名可以是 application-{profile}.properties/yml

默认使用application.properties的配置;

2、yml支持多文档块方式

  1. server:
  2. port:8081
  3. spring:
  4. profiles:
  5. active: prod
  6. ---
  7. server:
  8. port:8083
  9. spring:
  10. profiles: dev
  11. ---
  12. server:
  13. port:8084
  14. spring:
  15. profiles: prod #指定属于哪个环境

3、激活指定profile

​ 1、在配置文件中指定 spring.profiles.active=dev

​ 2、命令行:

​ java -jar spring-boot-02-config-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev;

​ 可以直接在测试的时候,配置传入命令行参数

​ 3、虚拟机参数;

​ -Dspring.profiles.active=dev

七、配置文件加载位置

springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件

–file:./config/

–file:./

–classpath:/config/

–classpath:/

优先级由高到底,高优先级的配置会覆盖低优先级的配置;

SpringBoot会从这四个位置全部加载主配置文件;互补配置

==我们还可以通过spring.config.location来改变默认的配置文件位置==

项目打包好以后,我们可以使用命令行参数的形式,启动项目的时候来指定配置文件的新位置;指定配置文件和默认加载的这些配置文件共同起作用形成互补配置;

java -jar spring-boot-02-config-02-0.0.1-SNAPSHOT.jar --spring.config.location=G:/application.properties

八、外部配置加载顺序

==SpringBoot也可以从以下位置加载配置; 优先级从高到低;高优先级的配置覆盖低优先级的配置,所有的配置会形成互补配置==

1.命令行参数

所有的配置都可以在命令行上进行指定

java -jar spring-boot-02-config-02-0.0.1-SNAPSHOT.jar --server.port=8087 --server.context-path=/abc

多个配置用空格分开; --配置项=值

2.来自java:comp/env的JNDI属性

3.Java系统属性(System.getProperties())

4.操作系统环境变量

5.RandomValuePropertySource配置的random.*属性值

==由jar包外向jar包内进行寻找;==

==优先加载带profile==

6.jar包外部的application-{profile}.properties或application.yml(带spring.profile)配置文件

7.jar包内部的application-{profile}.properties或application.yml(带spring.profile)配置文件

==再来加载不带profile==

8.jar包外部的application.properties或application.yml(不带spring.profile)配置文件

9.jar包内部的application.properties或application.yml(不带spring.profile)配置文件

10.@Configuration注解类上的@PropertySource

11.通过SpringApplication.setDefaultProperties指定的默认属性

所有支持的配置加载来源;

参考官方文档

8、自动配置原理

配置文件到底能写什么?怎么写?自动配置原理;

配置文件能配置的属性参照

1、自动配置原理:

1)、SpringBoot启动的时候加载主配置类,开启了自动配置功能 ==@EnableAutoConfiguration==

2)、@EnableAutoConfiguration 作用:

  • 利用EnableAutoConfigurationImportSelector给容器中导入一些组件?

    • 可以查看selectImports()方法的内容;

    • List configurations = getCandidateConfigurations(annotationMetadata, attributes);获取候选的配置

    1. SpringFactoriesLoader.loadFactoryNames()
    2. 扫描所有jar包类路径下 META-INF/spring.factories
    3. 把扫描到的这些文件的内容包装成properties对象
    4. properties中获取到EnableAutoConfiguration.class类(类名)对应的值,然后把他们添加在容器中

==将 类路径下 META-INF/spring.factories 里面配置的所有EnableAutoConfiguration的值加入到了容器中;==

  1. # Auto Configure
  2. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
  3. org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
  4. org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
  5. org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
  6. org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
  7. org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
  8. org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
  9. org.springframework.boot.autoconfigure.cloud.CloudAutoConfiguration,\
  10. org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\
  11. org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
  12. org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\
  13. org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\
  14. org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,
  15. ...

每一个这样的 xxxAutoConfiguration类都是容器中的一个组件,都加入到容器中;用他们来做自动配置;

3)、每一个自动配置类进行自动配置功能;

4)、以HttpEncodingAutoConfiguration(Http编码自动配置)为例解释自动配置原理;

  1. @Configuration//表示这是一个配置类,以前编写的配置文件一样,也可以给容器中添加组件
  2. @EnableConfigurationProperties(HttpEncodingProperties.class)//启动指定类的ConfigurationProperties功能;将配置文件中对应的值和HttpEncodingProperties绑定起来;并把HttpEncodingProperties加入到ioc容器中
  3. @ConditionalOnWebApplication//Spring底层@Conditional注解(Spring注解版),根据不同的条件,如果满足指定的条件,整个配置类里面的配置就会生效; 判断当前应用是否是web应用,如果是,当前配置类生效
  4. @ConditionalOnClass(CharacterEncodingFilter.class)//判断当前项目有没有这个类CharacterEncodingFilter;SpringMVC中进行乱码解决的过滤器;
  5. @ConditionalOnProperty(prefix ="spring.http.encoding", value ="enabled", matchIfMissing =true)//判断配置文件中是否存在某个配置 spring.http.encoding.enabled;如果不存在,判断也是成立的
  6. //即使我们配置文件中不配置pring.http.encoding.enabled=true,也是默认生效的;
  7. publicclassHttpEncodingAutoConfiguration{
  8. //他已经和SpringBoot的配置文件映射了
  9. privatefinalHttpEncodingProperties properties;
  10. //只有一个有参构造器的情况下,参数的值就会从容器中拿
  11. publicHttpEncodingAutoConfiguration(HttpEncodingProperties properties){
  12. this.properties = properties;
  13. }
  14. @Bean//给容器中添加一个组件,这个组件的某些值需要从properties中获取
  15. @ConditionalOnMissingBean(CharacterEncodingFilter.class)//判断容器没有这个组件?没有才加载
  16. publicCharacterEncodingFilter characterEncodingFilter(){
  17. CharacterEncodingFilter filter =newOrderedCharacterEncodingFilter();
  18. filter.setEncoding(this.properties.getCharset().name());
  19. filter.setForceRequestEncoding(this.properties.shouldForce(Type.REQUEST));
  20. filter.setForceResponseEncoding(this.properties.shouldForce(Type.RESPONSE));
  21. return filter;
  22. }

根据当前不同的条件判断,决定这个配置类是否生效?

一但这个配置类生效;这个配置类就会给容器中添加各种组件;这些组件的属性是从对应的properties类中获取的,这些类里面的每一个属性又是和配置文件绑定的;

5)、所有在配置文件中能配置的属性都是在xxxxProperties类中封装者‘;配置文件能配置什么就可以参照某个功能对应的这个属性类

  1. @ConfigurationProperties(prefix ="spring.http.encoding")//从配置文件中获取指定的值和bean的属性进行绑定
  2. publicclassHttpEncodingProperties{
  3. publicstaticfinalCharset DEFAULT_CHARSET =Charset.forName("UTF-8");

精髓:

1)、SpringBoot启动会加载大量的自动配置类

2)、我们看我们需要的功能有没有SpringBoot默认写好的自动配置类;

3)、我们再来看这个自动配置类中到底配置了哪些组件;(只要我们要用的组件有,我们就不需要再来配置了)

4)、给容器中自动配置类添加组件的时候,会从properties类中获取某些属性。我们就可以在配置文件中指定这些属性的值;

xxxxAutoConfigurartion:自动配置类;

给容器中添加组件

xxxxProperties:封装配置文件中相关属性;

2、细节

1、@Conditional派生注解(Spring注解版原生的@Conditional作用)

作用:必须是@Conditional指定的条件成立,才给容器中添加组件,配置配里面的所有内容才生效;

@Conditional扩展注解作用(判断是否满足当前指定条件)
@ConditionalOnJava系统的java版本是否符合要求
@ConditionalOnBean容器中存在指定Bean;
@ConditionalOnMissingBean容器中不存在指定Bean;
@ConditionalOnExpression满足SpEL表达式指定
@ConditionalOnClass系统中有指定的类
@ConditionalOnMissingClass系统中没有指定的类
@ConditionalOnSingleCandidate容器中只有一个指定的Bean,或者这个Bean是首选Bean
@ConditionalOnProperty系统中指定的属性是否有指定的值
@ConditionalOnResource类路径下是否存在指定资源文件
@ConditionalOnWebApplication当前是web环境
@ConditionalOnNotWebApplication当前不是web环境
@ConditionalOnJndiJNDI存在指定项

自动配置类必须在一定的条件下才能生效;

我们怎么知道哪些自动配置类生效;

==我们可以通过启用 debug=true属性;来让控制台打印自动配置报告==,这样我们就可以很方便的知道哪些自动配置类生效;

  1. =========================
  2. AUTO-CONFIGURATION REPORT
  3. =========================
  4. Positive matches:(自动配置类启用的)
  5. -----------------
  6. DispatcherServletAutoConfiguration matched:
  7. -@ConditionalOnClass found required class'org.springframework.web.servlet.DispatcherServlet';@ConditionalOnMissingClass did not find unwanted class(OnClassCondition)
  8. -@ConditionalOnWebApplication(required) found StandardServletEnvironment(OnWebApplicationCondition)
  9. Negative matches:(没有启动,没有匹配成功的自动配置类)
  10. -----------------
  11. ActiveMQAutoConfiguration:
  12. Did not match:
  13. -@ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory','org.apache.activemq.ActiveMQConnectionFactory'(OnClassCondition)
  14. AopAutoConfiguration:
  15. Did not match:
  16. -@ConditionalOnClass did not find required classes 'org.aspectj.lang.annotation.Aspect','org.aspectj.lang.reflect.Advice'(OnClassCondition)

转载于:https://www.cnblogs.com/chaoqi/p/10739739.html

相关文章:

关于 RMAN 备份 数据块 一致性的讨论

今天和 杭州恒生 的一个朋友讨论一个RMAN 在备份时数据块一致性的问题。 关于RMAN 的备份原理参考blog&#xff1a; RMAN 系列&#xff08;一&#xff09;---- RMAN 体系结构概述 http://blog.csdn.net/tianlesoftware/archive/2010/06/09/5659701.aspx 先看官方文档上的一段话…

常用git命令

常用 Git 命令清单。专用名词的译名如下。半支烟 Workspace&#xff1a;工作区Index / Stage&#xff1a;暂存区Repository&#xff1a;仓库区&#xff08;或本地仓库&#xff09;Remote&#xff1a;远程仓库一、新建代码库 # 在当前目录新建一个Git代码库 $ git init# 新建一个…

springboot 读取配置文件内容的几种方式

1 使用 Environment 进行读取 env.getProperty("配置文件中的值") 2 使用注解的方式 PropertySource("classpath:application.properties") // 获取属性文件 //将其注解到类上 获取属性值 Value("${pictureSearchDemo.apiUrl}") // 获取属性…

Ubuntu9.10使用windows的字体的方法!

使用Ubuntu9.10已经有好几天了&#xff0c;安装字体算是我遇到的比较头疼的一件事&#xff0c;原本按照Ubuntu9.04的方法操作&#xff0c;发现无法使用windows中的字体&#xff0c;换了好几个方法&#xff0c;最终找打了解决方法&#xff0c;过程如下&#xff1a;1、新建一个文…

jmeter笔记(8)--关联

关联是jmeter中比较重要的一个点&#xff0c;在测试过程中有些数据是经常发生变化的&#xff0c;要获取这些数据&#xff0c;就需要使用关联&#xff0c;Jmeter可以通过“后置处理器”中的“正则表达式提取器”来处理关联。。 正则表达式提取器 1、在取样器下点击【添加】--【后…

java连接mysql以及增删改查操作

java连接数据库的代码基本是固定的&#xff0c;步骤过程觉得繁琐些&#xff0c;代码记起来对我来说是闹挺。直接上代码&#xff1a; &#xff08;温馨提醒&#xff1a;你的项目提前导入连接数据库的jar包才有的以下操作 &#xff09; 1 class DBConnection{2 3 // 驱动类…

Jrebel 热部署插件的使用和破解

生成GUIDS 的网站&#xff1a;https://www.guidgen.com/ Jrebel 介绍和破解说明&#xff1a;https://www.cnblogs.com/wang1024/p/7211194.html 本地服务器软件,在使用eclipse或者idea 时打开就可以了。链接&#xff1a;百度云链接 密码&#xff1a;buin

微软SCRUM 1.0流程模板在中文版TFS2010上无法创建项目的解决办法(续)

原文&#xff1a; http://www.almnetworks.net/zh-CN/post/2010/08/04/Microsoft-Visual-Studio-Scrum-10-Template-on-Chinese-Version-of-TFS.aspx 经过我的进一步测试&#xff0c;发现以上步骤不能解决这个问题&#xff0c;但是我找到了一个可以暂时保证我们使用SCRUM模板的…

《父亲家书》选:给初为人师的儿子

文飞&#xff1a;离家已二十九天了&#xff0c;可能是年纪大了的缘故&#xff0c;不要说你妈妈&#xff0c;就连我也想念你了&#xff01;为不影响你工作&#xff0c;我坚持不够一个月“决”不给你去信。这不到期了&#xff0c;就按时给你去信。你上次来信&#xff0c;早已收到…

vue-cli脚手架

安装 全局环境安装&#xff0c;不必要在项目地址下安装&#xff1a;npm install -g vue-cli 卸载 全局卸载&#xff1a;npm uninstall -g vue-cli 查看是否安装成功&#xff1a;vue list 查看vue版本&#xff0c;vue -V 回车&#xff0c;查看vue最新的版本。 使用 进入到编辑器…

JackJson 使用记录

Map<String,Object> map new HashMap();map.put("ssss","sadsad");// 定义JackJson 对象ObjectMapper mapper new ObjectMapper();//将map转换成JSON字符串String image_json mapper.writeValueAsString(map); https://blog.csdn.net/a123demi/art…

APUE 学习笔记 - Chapter 6. System Data File and Infomation

1.密码文件 每个系统都会有一个文件统一记录用户名与密码&#xff0c;通常是/etc/passwd。关于这个文件有&#xff1a;root 的 uin 通常为 0 .文件中的 x为占位符&#xff0c;代表真实的加密密码保存在另外的文件。没有这一列的时候&#xff0c;表示该用户没有设立密码。将用户…

加密工具和unlocker的使用

在我的电脑上&#xff0c;一些不想让人翻看的程序和资料都使用一款《E-钻文件夹加密大师》的伪加密软件来加密。 这个程序只防君子不防小人&#xff0c;真正想看的人还是可以找到方法看的。并且这个软件还有些bug和不方便之处。 我在电脑上编程之前需要对多个代码文件夹进行解密…

第四章:操作列表

第四章&#xff1a;操作列表4.1 遍历整个列表如果名单很长&#xff0c;将包含大量反复的代码。另外&#xff0c;每当名单的长度发生变化时&#xff0c;都必须修改代码。通过for循环&#xff0c;可让Python去处理这些问题1&#xff09;使用for循环来打印魔术师名单中的所有名字&…

约束,索引,rownumrownum

--constraint --not null 非空约束 --unique 唯一键 --非空&唯一 --自定义检查约束 --创建约束时&#xff0c;为约束起名 --在添加完列后&#xff0c;还可以添加约束 --除了not null不可以 --主键约束 --为了保证该列的数据能够证明行记录在表中是唯一的 --主键约束从形式看…

微信小程序如何搭建本地环境开发

必要软件 ngrok :用来搭建内网穿透微信小程序开发工具微信小程序账号 如何使用ngrok 搭建内网穿透 在官网下载windows版本的ngrok&#xff0c;并且注册一个免费的账号&#xff0c;至此会给你生成一个认证码。ngrok官网&#xff0c;附一个下载好的文件&#xff0c;里包括官方版…

跨域部署Silverlight时需要注意的问题

当我们的Silverlight程序(.xap)发布地址和网页发布地址处于不同服务器上(跨域状态)时&#xff0c;由于安全机制在Silverlight和Javascript调用时会出现一些问题&#xff0c;如&#xff1a;Silverlight调用页面中的Javascript方法或页面中的Javscript调用Silverlight方法时报错或…

做国内最好的ITSM服务管理软件

E8.HelpDesk支持多种服务台管理体系&#xff0c;支持事件管理、问题管理、变更管理、配置管理、发布管理、运行管理的全程自动化&#xff1b;整个处理工作以流程自动化的任务贯穿&#xff0c;形成闭环的工作流&#xff0c;并有计划任务机制、报警提醒机制、事件升级机制、跟踪反…

AppBaseJs 类库 网上常用的javascript函数及其他js类库写的

AppBaseJs类库。一个借鉴了网上常用的函数及其他js类库写的,方便大家的调用。代码如下:/*----------------------------------- Web Application JavaScript Library 2009.11 janchie ------------------------------------*///String原生对象扩展 置空左右端空格 String.proto…

字符串转换整数 (atoi)

题目&#xff1a; 请你来实现一个 atoi 函数&#xff0c;使其能将字符串转换成整数。 首先&#xff0c;该函数会根据需要丢弃无用的开头空格字符&#xff0c;直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时&#xff0c;则将该符号与之后面尽可…

Spring boot 忽略对mybatis的配置

SpringBootApplication(exclude{DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}) https://blog.csdn.net/wo541075754/article/details/73379962

Git远程仓库地址变更

简单方法 使用方法三 方法有很多&#xff0c;这里简单介绍几种&#xff1a; 以下均以项目git_test为例&#xff1a; 老地址&#xff1a;http://192.168.1.12:9797/john/git_test.git 新地址&#xff1a;http://192.168.100.235:9797/john/git_test.git 远程仓库名称&#xff…

如何优化你的网站快速提高流量

网站页面优化的SEO策略 对那些会主动产生成百上千甚至成千上万页面的网站优化&#xff0c;一定要转换思维方式。传统SEO程序&#xff0c;先调查选定关键词&#xff0c;然后针对每个关键词主题产生页面&#xff0c;手动书写标题标签&#xff0c;段落标题标签 和页面简介&#xf…

c#正则表达式使用详解

正则表达式(Regular expressions)是一套语法匹配规则&#xff0c;各种语言&#xff0c;如Perl&#xff0c; .Net和Java都有其对应的共享的正则表达式类库。在.Net中&#xff0c;这个类库叫做Regex。简单的说&#xff0c;Regex是从字符窗中查找匹配字符串的应用类。通过Regex&am…

软件安装(ubuntu) --Linux基础编程

Ubuntu&#xff1a;一个以桌面应用为主的开源GNU/Linux操作系统 1、在线安装&#xff08;Ubuntu Example&#xff09; 【安装】&#xff1a;sudo apt-get install 安装包的名字&#xff0c;或者&#xff1a;sudo apt install 安装包的名字&#xff08;16.04及以上版本&#xff…

Springboot结合 framework 加载静资源 出现404 问题解决 记录

<!- 在HTML页面加入这样--><#assign ctxrequest.contextPath /> 在引入的静态资源路径上 添加以下内容

studyLink

http://order.csdn.net/myorder/detail?id850343 csdn 转载于:https://www.cnblogs.com/zhujiasheng/p/8010861.html

CCNA的一个综合实验(经典)

【背景描述】 该企业的具体环境如下&#xff1a; 1、企业具有2个办公地点&#xff0c;且相距较远&#xff0c;公司总共大约有200台主机。 2、A办公地点具有的部门较多&#xff0c;例如业务部、财务部、综合部等&#xff0c;为主要的办公场所&#xff0c;因此这部分的交换网络对…

关于EF中批量添加的个人探索

实际的测试代码和数据记录&#xff0c;还有最终的总结都在下面&#xff1a; /// <summary>/// 这种做法&#xff0c;不用了说了&#xff0c;每次遍历都会打开一次db链接&#xff0c;然后执行insert操作&#xff1b;/// </summary>static void CreateBluckInsertDat…

HDOJ 1157 HDU 1157 Who's in the Middle ACM 1157 IN HDU

MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid1157 题目描述:Whos in the MiddleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2451 Accep…