Spring中配置和读取多个Properties文件

2023-10-27

一个系统中通常会存在如下一些以Properties形式存在的配置文件

1.数据库配置文件demo-db.properties:

Properties代码   收藏代码
  1. database.url=jdbc:mysql://localhost/smaple  
  2. database.driver=com.mysql.jdbc.Driver  
  3. database.user=root  
  4. database.password=123  

 

2.消息服务配置文件demo-mq.properties:

Properties代码   收藏代码
  1. #congfig of ActiveMQ  
  2. mq.java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory  
  3. mq.java.naming.provider.url=failover:(tcp://localhost:61616?soTimeout=30000&connectionTimeout=30000)?jms.useAsyncSend=true&timeout=30000  
  4. mq.java.naming.security.principal=  
  5. mq.java.naming.security.credentials=  
  6. jms.MailNotifyQueue.consumer=5  

 

3.远程调用的配置文件demo-remote.properties:

Properties代码   收藏代码
  1. remote.ip=localhost  
  2. remote.port=16800  
  3. remote.serviceName=test  

 

一、系统中需要加载多个Properties配置文件

应用场景:Properties配置文件不止一个,需要在系统启动时同时加载多个Properties文件。

配置方式:

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="  
  5.     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
  6.       
  7.     <!-- 将多个配置文件读取到容器中,交给Spring管理 -->  
  8.     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  9.         <property name="locations">  
  10.            <list>  
  11.               <!-- 这里支持多种寻址方式:classpath和file -->  
  12.               <value>classpath:/opt/demo/config/demo-db.properties</value>  
  13.               <!-- 推荐使用file的方式引入,这样可以将配置和代码分离 -->  
  14.               <value>file:/opt/demo/config/demo-mq.properties</value>  
  15.               <value>file:/opt/demo/config/demo-remote.properties</value>  
  16.             </list>  
  17.         </property>  
  18.     </bean>  
  19.       
  20.     <!-- 使用MQ中的配置 -->  
  21.     <bean id="MQJndiTemplate" class="org.springframework.jndi.JndiTemplate">  
  22.         <property name="environment">  
  23.             <props>  
  24.                 <prop key="java.naming.factory.initial">${mq.java.naming.factory.initial}</prop>  
  25.                 <prop key="java.naming.provider.url">${mq.java.naming.provider.url}</prop>  
  26.                 <prop key="java.naming.security.principal">${mq.java.naming.security.principal}</prop>  
  27.                 <prop key="java.naming.security.credentials">${mq.java.naming.security.credentials}</prop>  
  28.                 <prop key="userName">${mq.java.naming.security.principal}</prop>  
  29.                 <prop key="password">${mq.java.naming.security.credentials}</prop>  
  30.             </props>  
  31.         </property>  
  32.     </bean>  
  33. </beans>  

 我们也可以将配置中的List抽取出来:

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="  
  5.     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
  6.       
  7.     <!-- 将多个配置文件位置放到列表中 -->  
  8.     <bean id="propertyResources" class="java.util.ArrayList">  
  9.         <constructor-arg>  
  10.             <list>  
  11.               <!-- 这里支持多种寻址方式:classpath和file -->  
  12.               <value>classpath:/opt/demo/config/demo-db.properties</value>  
  13.               <!-- 推荐使用file的方式引入,这样可以将配置和代码分离 -->  
  14.               <value>file:/opt/demo/config/demo-mq.properties</value>  
  15.               <value>file:/opt/demo/config/demo-remote.properties</value>  
  16.             </list>  
  17.         </constructor-arg>  
  18.     </bean>  
  19.       
  20.     <!-- 将配置文件读取到容器中,交给Spring管理 -->  
  21.     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  22.         <property name="locations" ref="propertyResources" />  
  23.     </bean>  
  24.       
  25.     <!-- 使用MQ中的配置 -->  
  26.     <bean id="MQJndiTemplate" class="org.springframework.jndi.JndiTemplate">  
  27.         <property name="environment">  
  28.             <props>  
  29.                 <prop key="java.naming.factory.initial">${mq.java.naming.factory.initial}</prop>  
  30.                 <prop key="java.naming.provider.url">${mq.java.naming.provider.url}</prop>  
  31.                 <prop key="java.naming.security.principal">${mq.java.naming.security.principal}</prop>  
  32.                 <prop key="java.naming.security.credentials">${mq.java.naming.security.credentials}</prop>  
  33.                 <prop key="userName">${mq.java.naming.security.principal}</prop>  
  34.                 <prop key="password">${mq.java.naming.security.credentials}</prop>  
  35.             </props>  
  36.         </property>  
  37.     </bean>  
  38. </beans>  

 

二、整合多工程下的多个分散的Properties

应用场景:工程组中有多个配置文件,但是这些配置文件在多个地方使用,所以需要分别加载。

配置如下:

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:p="http://www.springframework.org/schema/p"  
  5.     xsi:schemaLocation="  
  6.     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
  7.       
  8.     <!-- 将DB属性配置文件位置放到列表中 -->  
  9.     <bean id="dbResources" class="java.util.ArrayList">  
  10.         <constructor-arg>  
  11.         <list>  
  12.             <value>file:/opt/demo/config/demo-db.properties</value>  
  13.         </list>  
  14.         </constructor-arg>  
  15.     </bean>  
  16.   
  17.     <!-- 将MQ属性配置文件位置放到列表中 -->  
  18.     <bean id="mqResources" class="java.util.ArrayList">  
  19.         <constructor-arg>  
  20.         <list>  
  21.             <value>file:/opt/demo/config/demo-mq.properties</value>  
  22.         </list>  
  23.         </constructor-arg>  
  24.     </bean>  
  25.       
  26.     <!-- 用Spring加载和管理DB属性配置文件 -->  
  27.     <bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  28.         <property name="order" value="1" />  
  29.         <property name="ignoreUnresolvablePlaceholders" value="true" />   
  30.         <property name="locations" ref="dbResources" />  
  31.     </bean>  
  32.       
  33.     <!-- 用Spring加载和管理MQ属性配置文件 -->  
  34.     <bean id="mqPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  35.         <property name="order" value="2" />  
  36.         <property name="ignoreUnresolvablePlaceholders" value="true" />   
  37.         <property name="locations" ref="mqResources" />  
  38.     </bean>  
  39.       
  40.     <!-- 使用DB中的配置属性 -->  
  41.     <bean id="rmsDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"   
  42.         p:driverClassName="${demo.db.driver}" p:url="${demo.db.url}" p:username="${demo.db.username}"   
  43.         p:password="${demo.db.password}" pp:maxActive="${demo.db.maxactive}"p:maxWait="${demo.db.maxwait}"   
  44.         p:poolPreparedStatements="true" p:defaultAutoCommit="false">  
  45.     </bean>  
  46.       
  47.     <!-- 使用MQ中的配置 -->  
  48.     <bean id="MQJndiTemplate" class="org.springframework.jndi.JndiTemplate">  
  49.         <property name="environment">  
  50.             <props>  
  51.                 <prop key="java.naming.factory.initial">${mq.java.naming.factory.initial}</prop>  
  52.                 <prop key="java.naming.provider.url">${mq.java.naming.provider.url}</prop>  
  53.                 <prop key="java.naming.security.principal">${mq.java.naming.security.principal}</prop>  
  54.                 <prop key="java.naming.security.credentials">${mq.java.naming.security.credentials}</prop>  
  55.                 <prop key="userName">${mq.java.naming.security.principal}</prop>  
  56.                 <prop key="password">${mq.java.naming.security.credentials}</prop>  
  57.             </props>  
  58.         </property>  
  59.     </bean>  
  60. </beans>  

 注意:其中order属性代表其加载顺序,而ignoreUnresolvablePlaceholders为是否忽略不可解析的 Placeholder,如配置了多个PropertyPlaceholderConfigurer,则需设置为true。这里一定需要按照这种方式设置这两个参数。

 

三、Bean中直接注入Properties配置文件中的值

应用场景:Bean中需要直接注入Properties配置文件中的值 。例如下面的代码中需要获取上述demo-remote.properties中的值:

Java代码   收藏代码
  1. public class Client() {  
  2.     private String ip;  
  3.     private String port;  
  4.     private String service;  
  5. }  

 配置如下:

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"  
  3.  xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"  
  4.  xmlns:util="<a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a>"  
  5.  xsi:schemaLocation="  
  6.  <a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</a>  
  7.  <a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a> <a href="http://www.springframework.org/schema/util/spring-util-3.0.xsd">http://www.springframework.org/schema/util/spring-util-3.0.xsd</a>">  
  8.    
  9.  <!-- 这种加载方式可以在代码中通过@Value注解进行注入,   
  10.  可以将配置整体赋给Properties类型的类变量,也可以取出其中的一项赋值给String类型的类变量 -->  
  11.  <!-- <util:properties/> 标签只能加载一个文件,当多个属性文件需要被加载的时候,可以使用多个该标签 -->  
  12.  <util:properties id="remoteSettings" location="file:/opt/demo/config/demo-remote.properties" />   
  13.    
  14.  <!-- <util:properties/> 标签的实现类是PropertiesFactoryBean,  
  15.  直接使用该类的bean配置,设置其locations属性可以达到一个和上面一样加载多个配置文件的目的 -->  
  16.  <bean id="settings"   
  17.    class="org.springframework.beans.factory.config.PropertiesFactoryBean">  
  18.    <property name="locations">  
  19.   <list>  
  20.     <value>file:/opt/rms/config/rms-mq.properties</value>  
  21.     <value>file:/opt/rms/config/rms-env.properties</value>  
  22.   </list>  
  23.    </property>  
  24.  </bean>  
  25. </beans>  

 Client类中使用Annotation如下:

Java代码   收藏代码
  1. import org.springframework.beans.factory.annotation.Value;  
  2.   
  3. public class Client() {  
  4.     @Value("#{remoteSettings['remote.ip']}")  
  5.     private String ip;  
  6.     @Value("#{remoteSettings['remote.port']}")  
  7.     private String port;  
  8.     @Value("#{remoteSettings['remote.serviceName']}")  
  9.     private String service;  
  10. }  

 

四、Bean中存在Properties类型的类变量

应用场景:当Bean中存在Properties类型的类变量需要以注入的方式初始化

1. 配置方式:我们可以用(三)中的配置方式,只是代码中注解修改如下

Java代码   收藏代码
  1. import org.springframework.beans.factory.annotation.Value;  
  2. import org.springframework.beans.factory.annotation.Autowired;  
  3.   
  4. public class Client() {  
  5.     @Value("#{remoteSettings}")  
  6.     private Properties remoteSettings;  
  7. }  

 

2. 配置方式:也可以使用xml中声明Bean并且注入

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="  
  5.     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
  6.       
  7.     <!-- 可以使用如下的方式声明Properties类型的FactoryBean来加载配置文件,这种方式就只能当做Properties属性注入,而不能获其中具体的值 -->  
  8.     <bean id="remoteConfigs" class="org.springframework.beans.factory.config.PropertiesFactoryBean">  
  9.         <property name="locations">  
  10.             <list>  
  11.                 <value>file:/opt/demo/config/demo-remote.properties</value>  
  12.             </list>  
  13.         </property>  
  14.     </bean>  
  15.       
  16.     <!-- 远端调用客户端类 -->  
  17.     <bean id="client" class="com.demo.remote.Client">  
  18.         <property name="properties" ref="remoteConfigs" />  
  19.     </bean>  
  20. </beans>  

代码如下:

Java代码   收藏代码
  1. import org.springframework.beans.factory.annotation.Autowired;  
  2.   
  3. public class Client() {  
  4.     //@Autowired也可以使用  
  5.     private Properties remoteSettings;  
  6.       
  7.     //getter setter  
  8. }  

 

上述的各个场景在项目群中特别有用,需要灵活的使用上述各种配置方式。


在很多情况下我们需要在配置文件中配置一些属性,然后注入到bean中,Spring提供了org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer类,可以方便我们使用注解直接注入properties文件中的配置。

下面我们看下具体如何操作:

首先要新建maven项目,并在pom文件中添加spring依赖,如下pom.xml文件:

<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>cn.outofmemory</groupId>
  <artifactId>hellospring.properties.annotation</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>hellospring.properties.annotation</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <org.springframework-version>3.0.0.RC2</org.springframework-version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>              
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
  </dependencies>
</project>

要自动注入properties文件中的配置,需要在spring配置文件中添加org.springframework.beans.factory.config.PropertiesFactoryBeanorg.springframework.beans.factory.config.PreferencesPlaceholderConfigurer的实例配置:

如下spring配置文件appContext.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: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/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd ">
    <!-- bean annotation driven -->
    <context:annotation-config />
    <context:component-scan base-package="cn.outofmemory.hellospring.properties.annotation">
    </context:component-scan>
    <bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath*:application.properties</value>
            </list>
        </property>
    </bean>
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
        <property name="properties" ref="configProperties" />
    </bean>    
</beans>

在这个配置文件中我们配置了注解扫描,和configProperties实例和propertyConfigurer实例。这样我们就可以在java类中自动注入配置了,我们看下java类中如何做:

package cn.outofmemory.hellospring.properties.annotation;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MySQLConnectionInfo {

    @Value("#{configProperties['mysql.url']}")
    private String url;
    @Value("#{configProperties['mysql.userName']}")
    private String userName;
    @Value("#{configProperties['mysql.password']}")
    private String password;

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }
}

自动注入需要使用@Value注解,这个注解的格式#{configProperties['mysql.url']}其中configProperties是我们在appContext.xml中配置的beanId,mysql.url是在properties文件中的配置项。

properties文件的内容如下:

mysql.url=mysql's url
mysql.userName=mysqlUser
mysql.password=mysqlPassword

最后我们需要测试一下以上写法是否有问题,如下App.java文件内容:

package cn.outofmemory.hellospring.properties.annotation;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("appContext.xml");
        MySQLConnectionInfo connInfo = appContext.getBean(MySQLConnectionInfo.class);
        System.out.println(connInfo.getUrl());
        System.out.println(connInfo.getUserName());
        System.out.println(connInfo.getPassword());
    }
}

在main方法中首先声明了appContext,然后获得了自动注入的MySQLConnectionInfo的实例,然后打印出来,运行程序会输出配置文件中配置的值


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring中配置和读取多个Properties文件 的相关文章

  • 曼哈顿距离,欧式距离,余弦距离

    1 曼哈顿距离 曼哈顿距离 叫出租车距离的 具见上图黄线 应该就能明白 计算距离最简单的方法是曼哈顿距离 假设 先考虑二维情况 只有两个乐队 x 和 y 用户A的评价为 x1 y1 用户B的评价为 x2 y2 那么 它们之间的曼哈顿距离为
  • MySQL客户端软件(DBeaver)连接报错解决方案

    1 mysql出现错误提示 Communications link failure The last packet sent successfully to the server was 0 mi 无论是在mysql客户端连接 或者是cod
  • DC靶场系列--DC1

    目录 引言 搭建环境 信息收集 漏洞分析 漏洞利用 引言 DC靶场 主要是通过web渗透技术 拿到web服务器的权限 会有flag做为标记 以拿到最终的flag为目标 DC1是vulnhub平台下的DC系列的第一个靶场 DC系列下载地址 官
  • 长角牛网络监听 arp欺骗

    一 原理 arp欺骗和攻击的原理是一样的 都是向目标计算机投毒 发送虚假ip地址对应的mac地址 致使被投毒计算机数据被窃听或者数据被盗取 多数情况欺骗和攻击会发生在计算机和网关的连接过程中 给目标计算机发送假的网关ip对应的mac地址 可
  • 【SDL实践指南】安全培训介绍

    转载自 SDL实践指南 安全培训介绍 腾讯云开发者社区 腾讯云https cloud tencent com developer article 2235019 文章前言 安全并不仅仅是安全团队的本职工作 也是企业的每个研发人员 产品经理
  • windows通过注册表修改3389端口号

    span style color FF0000 windows通过注册表修改3389端口号 步骤如下 span 1 开始 rarr 运行 输入regedit 打开注册表 进入这个路径HKEY LOCAL MACHINE SYSTEM Cur
  • 【波浪动态特效】基于jquery实现页面底部波浪动画效果(附完整源码下载)

    文章目录 写在前面 涉及知识点 实现效果 1 搭建页面 1 1 创建两个片区 1 2 创建波浪区域 1 3 静态页面源码 2 JS实现波浪效果 2 1 动画原理 2 2 动画源码 3 源码分享 3 1 百度网盘 3 2 123云盘 3 3
  • 图像识别(一) 之 灰度共生矩阵(GLDM)

    一 灰度共生矩阵 灰度共生矩阵被定义为从灰度为i的像素点出发 离开某个固定位置 相隔距离为d 方位为 的点上灰度值为的概率 1 计算方法 如上图 GLCM i j 的值呢就是I中像素为i 像素为j的有有多少和相邻的成对点 图上的 相邻 指的
  • 在VUE3中使用Pinia

    一 安装使用Pinia 安装下载 npm install pinia main js引入 import createPinia from pinia app use createPinia 根目录新建store index js中写入 im
  • ubuntu20.04 安装Anaconda3+CUDA+cudnn+Pytorch

    ubuntu20 04 安装Anaconda3 CUDA cudnn Pytorch Ubuntu GPU驱动 CUDA版本 CuDNN 版本 都要相互关联 版本不对应的话 就会出错 版本确认顺序 CUDA版本 gt CuDNN版本 gt
  • 反射、泛型详解

    反射 Class文件所包含的内容都有其对应的方法可以获得 创建Class对象的3种方式 方式一 类 class Class personClass Person class 方式二 对象 getClass Person person new
  • 《算法学习》C语言中“ const * “与“ * const “区别总结

    一 简介 最近重新学习了C语言中的指针 本文总结一下C语言中使用 的心得 二 总结 const 表示指针变量是constant 恒定的 不允许通过访问指针地址的方式改变指针所指地址的的值 const 表示该指针是恒定的 即该指针不能再指向别
  • 修改外向交货单:BAPI_OUTB_DELIVERY_CHANGE/SD_DELIVERY_UPDATE_PICKING_SAP刘梦_新浪博客

    TABLES LIKP PARAMETERS P DEL LIKE LIKP VBELN DEFAULT 8000002260 DATA STR HEADER DATA LIKE BAPIOBDLVHDRCHG STR HEADER CON
  • POJ-1240(分治,递归降解)

    题目 http poj org problem id 1240 题目的意思即 给定一棵m元树的前序和后序遍历 问你一共有多少颗m元树有这样的性质 乍一看好像没什么头绪 由于题目中也提到了由中序和后序求前序 想到是不是同样能用分治法 我们知道
  • 在阿里云服务器上部署Jekyll博客

    Step 0 首先买一台服务器 并且装好环境 我都是在阿里云上面买 而且我只是想挂一个个人网站 所以只需要最便宜的轻量应用服务器就好 半年只需要72块钱 我现在想来 之前也应该买香港的服务器 因为更加便宜 大陆的要60块一月 而且不需要给服
  • 初识ASO

    大概了解了一下ASO 在此记录一下 ASO 应用商店优化 的简称 ASO App Search Optimization 重点在于关键词搜索排名优化 覆盖热词 搜索下载激活 优化评论 关键词覆盖数量优化 就是指用户搜索更多关键词都能找到该款
  • VS Code(Visual Studio Code)环境下C++开发的配置方法

    一 Visual Studio Code的下载 去官网下载 下载地址 https code visualstudio com Download 我在windows系统下使用 直接点击Windows那个图标下载就好 安装时可以自己选择一下安装
  • layui源码详细分析之树形菜单

    前言 今天分析的是layui框架内置模块tree js 该模块的功能是构建树形菜单 具体的形式 layui官网该模块的具体形式 如下 自实现树形菜单 使用html css js实现了树形菜单 具体的实现思路如下 html中定义包含树形菜单的
  • C++选择结构学案

    学习目标 熟练掌握 C 中的关系 逻辑运算符 熟知关系 逻辑运算符和数学运算符的优先级 学会正确使用选择表达式 知识着陆 1 关系运算符 使用关系运算符需要注意的问题 1 等于 与 赋值 的区别 2 实型数据 浮点数 的关系运算 3 运算符

随机推荐

  • 锚点的作用及用法

    锚点的作用及用法 HTML中的a标签大家都非常熟悉 它是超链接标签 通过a标签能够跳转到href中指定的页面及指定的位置 a标签可以做到单页面跳转或多页面跳转 锚点能够跳转到当前页面中指定的位置 也能够跳转到指定的其他页面或其他页面中指定的
  • anaconda怎么运行python程序_PyCharm运行Python程序

    介绍如何使用 PyCharm 创建 Python 项目 以及如何编写并运行 Python 程序 PyCharm创建Python项目 PyCharm 中 往往是通过项目来管理 Python 源代码文件的 虽然对于第一个 Python 程序来说
  • java中的String类型的对象为什么可以自动转换成Object类型的?而Object却要强制转换成String类型的

    java中的String类型的对象为什么可以自动转换成Object类型的 而Object却要强制转换成String类型的 5 比如 String a hello Object b a 这样可以直接用 而 Object a hello Str
  • vue鼠标点击指定区域创建dom元素与编辑删除元素的思路

    vue鼠标点击指定区域创建dom元素与编辑删除元素的思路 话不多说有思路直接干 一 鼠标点击页面灰色背景创建红色元素 二 点击已经创建的红色元素则是编辑或者删除 根据点击元素的类名来判断是属于创建元素还是编辑或者删除元素 e target
  • 多个checkpoint 的参数进行平均

    source model 路径下 存在 以下几个checkpoint model checkpoint path model ckpt 457157707 all model checkpoint paths model ckpt 4560
  • 动手学深度学习d2l.Animator无法在PyCharm中显示动态图片的解决方案

    from d2l import torch as d2l 一 问题描述 运行d2l的训练函数 仅在控制台输出以下内容 无法显示动态图片 训练监控
  • notepad++ 正则表达式

    转载自 https www cnblogs com winstonet p 10635043 html 注意 Notepad 正则表达式字符串最长不能超过69个字符 转义字符 如 要使用 本身 则应该使用 t Tab制表符 注 扩展和正则表
  • 5. C++知识点之else分支

    上篇文章我们说了if语句 这篇文章我们再来说说if语句的后半部分 else if但分支选择结构在条件为真时采取操作 条件为假时则忽略这个操作 利用if else双分支选择结构则可以在条件为真时和条件和假时采取不同操作 格式 格式1 if 条
  • 论文阅读之Arcface

    Arcface论文阅读 文章目录 Arcface论文阅读 人脸识别流程 数据 VGG2 MS Celeb 1M MegaFace LFW CPF AgeDB 损失层 Softmax Loss Center Loss A Softmax Lo
  • 调试三角形

    图形sdk 一般是从三角形开始的 先运行下 还好 能过 要不白费劲了 是一个旋转的三角形 看看代码 先折叠下 猜测大概有啥东西 如果我写 该怎么写 顶点数组 索引数组 应用 创建 清理 动画 运行 配置 顶点数组和索引是传到三角形的 创建和
  • 版本更新

    MyEclipse是开源工具Eclispse的进一步扩展 是目前最实惠 功能最全面的J2EE IDE与Web开发工具套件 MyEclipse可用于用户所有的UML AJAX Web Web Services J2EE JSP XML Str
  • jvm调优一、linux内存查看命令

    1 整体情况查看 任务管理器 top 第三行就是CPU的使用情况了 如下 Cpu s us用户空间占用CPU百分比sy内核空间占用CPU百分比ni用户进程空间内改变过优先级的进程占用CPU百分比id空闲CPU百分比wa等待输入输出的CPU时
  • 多线程(三)

    Java 208 道面试题 多线程 35 并行和并发有什么区别 并行是指两个或者多个事件在同一时刻发生 而并发是指两个或多个事件在同一时间间隔发生 并行是在不同实体上的多个事件 并发是在同一实体上的多个事件 在一台处理器上 同时 处理多个任
  • valgrind:内存泄漏的检查工具

    valgrind 是帮助程序员寻找程序里的 bug 和改进程序性能的工具集 擅长发现内存的管理问题 里面有若干工具 其中最重要的是 memcheck 工具 用于检查内存的泄漏 memcheck 能发现如下的问题 使用未初始化的内存 使用已经
  • 【Shell编程】Shell中Bash变量-数值运算、运算符变量、测试和内容替换

    系列文章 Shell编程 Shell基本概述与脚本执行方式 Shell编程 Shell中Bash基本功能 Shell编程 Shell中Bash变量 用户自定义变量 Shell编程 Shell中Bash变量 位置参数变量 Shell编程 Sh
  • 【Leetcode】反转链表 合并链表 相交链表 链表的回文结构

    目录 一 Leetcode206 反转链表 1 链接 2 题目再现 3 解法A 三指针法 二 Leetcode21 合并两个有序链表 1 链接 2 题目再现 3 三指针尾插法 三 Leetcode160 相交链表 1 链接 2 题目再现 3
  • 2240. 买钢笔和铅笔的方案数

    文章目录 Tag 题目来源 题目解读 解题思路 复杂度分析 写在最后 Tag 枚举 数学 题目来源 2240 买钢笔和铅笔的方案数 题目解读 现在你有一笔钱 total 用来购买钢笔和铅笔 它们的价格分别为 cost1 和 cost2 试问
  • cocos creator修改EditorBox,去掉EditorBox的输入历史记录显示,cocos creator屏蔽输入框的历史记录显示

    cocos creator 3 3 2 修改EditorBox的历史记录就需要修改引擎源码 这里找到安装下的引擎源码C CocosDashboard 1 0 11 resources editors Creator 3 3 2 resour
  • ElasticSearch 总结

    ElasticSearch 将需要存储的数据分为 结构化数据 非结构化数据 半结构化数据 结构化数据 一般为二维的表结构 比如一张表包含了用户的姓名性别年龄等信息 一般保存到关系型数据库中 如 MySQL 非结构化数据 是无法用二维表结构表
  • Spring中配置和读取多个Properties文件

    一个系统中通常会存在如下一些以Properties形式存在的配置文件 1 数据库配置文件demo db properties Properties代码 database url jdbc mysql localhost smaple dat