system.getproperty,puk是什么意思

伏羲号

system.getproperty,puk是什么意思?

比如,

system.getproperty,puk是什么意思

vs,单词versus的简写,是对、相对的意思。读作['vɝsəs]而不是[vi'es]

PK,player killing,玩家对决

K.O.,knock out,击倒对手

手机和电脑、网络领域经常说到的:CPU,Central Processing Unit,中央处理单元IC,Integrated Circuit,集成电路iOS,i Operating System,苹果iPhone、iPad、iPod的操作系统

SIM卡,SIM卡是(Subscriber Identification Module ),也称为用户身份识别卡、智能卡,GSM数字移动电话机必须装上此卡方能使用。就是电话卡

PIN,Personal Identification Number,SIM卡的个人识别密码。手机的PIN码是保护SIM卡的一种安全措施,防止别人盗用SIM卡,如果启用了开机PIN码,那么每次开机后就要输入4位数PIN码。初始PIN为1234,可修改为4-8位。在输入三次PIN码错误时,手机便会自动锁卡,并提示输入PUK码解锁,需要使用服务密码拨打运营商客服热线,客服会告知初始的PUK码,输入PUK码之后就会解锁PIN码。

PUK,PIN Unblocking Key,当手机PIN码被锁,并提示输入PUK码时,千万不要轻举妄动,因为PUK码只有10次输入机会,10次都输错的话,SIM卡将会被永久锁死,也就是报废。

MAC,Mac是苹果公司自1984年起以“Macintosh”开始开发的个人消费型计算机,如:iMac、Mac mini、Macbook Air、Macbook Pro、Macbook、Mac Pro等计算机。使用独立的Mac OS系统,最新的OS X系列基于NeXT系统开发,不支持兼容。是一套完备而独立的操作系统。

还有一个常用的意思:

MAC(Media Access Control或者Medium Access Control)地址,意译为媒体访问控制,或称为物理地址、硬件地址,用来定义网络设备的位置。

MAC地址是网卡决定的,是固定的。

长度是48比特(6字节),由16进制的数字组成,一般在记录时用‘:’号分开写每个字节的数字且用16进制表示。比如:aa:bb:cc:dd:ee:ff:01

IP,互联网协议(Internet Protocol);知识产权(IntelleCTual Property)

汽车领域:

ABS,Antilock Brake System,防抱死刹车系统

SUV,Sports Utility Vehicle,运动型多用途车

APM,Automated People Mover systems,广州有这么一条线路

4S店,全称为汽车销售服务4S店(Automobile Sales Servicshop 4S),是一种集整车销售(Sale)、零配件(Sparepart)、售后服务(Service)、信息反馈(Survey)四位一体的汽车销售企业。

FAST:2017年大多数人都应该了解的——500米口径球面射电望远镜(Five-hundred-meter Aperture Spherical radio Telescope),简称FAST,位于贵州省黔南布依族苗族自治州平塘县大窝凼的喀斯特洼坑中。

500米口径球面射电望远镜被誉为“中国天眼”,由我国天文学家南仁东于1994年提出构想,历时22年建成,于2016年9月25日落成启用。是由中国科学院国家天文台主导建设,具有我国自主知识产权、世界最大单口径、最灵敏的射电望远镜。

B超:

CT:CT(Computed Tomography),即电子计算机断层扫描,它是利用精确准直的X线束、γ射线、超声波等,与灵敏度极高的探测器一同围绕人体的某一部位作一个接一个的断面扫描,具有扫描时间快,图像清晰等特点,可用于多种疾病的检查;根据所采用的射线不同可分为:X射线CT(X-CT)、超声CT(UCT)以及γ射线CT(γ-CT)等。

商业、网络

P2P:Peer to Peer

部分内容来自百度。

SpringBoot是如何动起来的?

程序入口

SpringApplication.run(BeautyApplication.class, args);

执行此方法来加载整个SpringBoot的环境。

1. 从哪儿开始?

SpringApplication.java

/**

* Run the Spring application, creating and refreshing a new

* {@link ApplicationContext}.

* @param args the application arguments (usually passed from a Java main method)

* @return a running {@link ApplicationContext}

*/

public ConfigurableApplicationContext run(String... args) {

//...

}

调用SpringApplication.java 中的 run 方法,目的是加载Spring Application,同时返回 ApplicationContext。

2. 执行了什么?

2.1 计时

记录整个Spring Application的加载时间!

StopWatch stopWatch = new StopWatch();

stopWatch.start();

// ...

stopWatch.stop();

if (this.logStartupInfo) {

new StartupInfoLogger(this.mainApplicationClass)

.logStarted(getApplicationLog(), stopWatch);

}

2.2 声明

指定 java.awt.headless,默认是true 一般是在程序开始激活headless模式,告诉程序,现在你要工作在Headless mode下,就不要指望硬件帮忙了,你得自力更生,依靠系统的计算能力模拟出这些特性来。

private void configureHeadlessProperty() {

System.setProperty(SYSTEM_PROPERTY_JAVA_AWT_HEADLESS, System.getProperty(

SYSTEM_PROPERTY_JAVA_AWT_HEADLESS, Boolean.toString(this.headless)));

}

2.4 配置监听并发布应用启动事件

SpringApplicationRunListener 负责加载 ApplicationListener事件。

SpringApplicationRunListeners listeners = getRunListeners(args);

// 开始

listeners.starting();

// 处理所有 property sources 配置和 profiles 配置,准备环境,分为标准 Servlet 环境和标准环境

ConfigurableEnvironment environment = prepareEnvironment(listeners,applicationArguments);

// 准备应用上下文

prepareContext(context, environment, listeners, applicationArguments,printedBanner);

// 完成

listeners.started(context);

// 异常

handleRunFailure(context, ex, exceptionReporters, listeners);

// 执行

listeners.running(context);

getRunListeners 中根据 type = SpringApplicationRunListener.class 去拿到了所有的 Listener 并根据优先级排序。

对应的就是 META-INF/spring.factories 文件中的 org.springframework.boot.SpringApplicationRunListener=org.springframework.boot.context.event.EventPublishingRunListener

private <T> Collection<T> getSpringFactoriesInstances(Class<T> type,

Class<?>[] parameterTypes, Object... args) {

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

// Use names and ensure unique to protect against duplicates

Set<String> names = new LinkedHashSet<>(

SpringFactoriesLoader.loadFactoryNames(type, classLoader));

List<T> instances = createSpringFactoriesInstances(type, parameterTypes,

classLoader, args, names);

AnnotationAwareOrderComparator.sort(instances);

return instances;

}

复制代码

在 ApplicationListener 中 , 可以针对任何一个阶段插入处理代码。

public interface SpringApplicationRunListener {

/**

* Called immediately when the run method has first started. Can be used for very

* early initialization.

*/

void starting();

/**

* Called once the environment has been prepared, but before the

* {@link ApplicationContext} has been created.

* @param environment the environment

*/

void environmentPrepared(ConfigurableEnvironment environment);

/**

* Called once the {@link ApplicationContext} has been created and prepared, but

* before sources have been loaded.

* @param context the application context

*/

void contextPrepared(ConfigurableApplicationContext context);

/**

* Called once the application context has been loaded but before it has been

* refreshed.

* @param context the application context

*/

void contextLoaded(ConfigurableApplicationContext context);

/**

* The context has been refreshed and the application has started but

* {@link CommandLineRunner CommandLineRunners} and {@link ApplicationRunner

* ApplicationRunners} have not been called.

* @param context the application context.

* @since 2.0.0

*/

void started(ConfigurableApplicationContext context);

/**

* Called immediately before the run method finishes, when the application context has

* been refreshed and all {@link CommandLineRunner CommandLineRunners} and

* {@link ApplicationRunner ApplicationRunners} have been called.

* @param context the application context.

* @since 2.0.0

*/

void running(ConfigurableApplicationContext context);

/**

* Called when a failure occurs when running the application.

* @param context the application context or {@code null} if a failure occurred before

* the context was created

* @param exception the failure

* @since 2.0.0

*/

void failed(ConfigurableApplicationContext context, Throwable exception);

}

3. 每个阶段执行的内容

3.1 listeners.starting();

在加载Spring Application之前执行,所有资源和环境未被加载。

3.2 prepareEnvironment(listeners, applicationArguments);

创建 ConfigurableEnvironment; 将配置的环境绑定到Spring Application中;

private ConfigurableEnvironment prepareEnvironment(

SpringApplicationRunListeners listeners,

ApplicationArguments applicationArguments) {

// Create and configure the environment

ConfigurableEnvironment environment = getOrCreateEnvironment();

configureEnvironment(environment, applicationArguments.getSourceArgs());

listeners.environmentPrepared(environment);

bindToSpringApplication(environment);

if (this.webApplicationType == WebApplicationType.NONE) {

environment = new EnvironmentConverter(getClassLoader())

.convertToStandardEnvironmentIfNecessary(environment);

}

ConfigurationPropertySources.attach(environment);

return environment;

}

3.3 prepareContext

配置忽略的Bean;

private void configureIgnoreBeanInfo(ConfigurableEnvironment environment) {

if (System.getProperty(

CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME) == null) {

Boolean ignore = environment.getProperty("spring.beaninfo.ignore",

Boolean.class, Boolean.TRUE);

System.setProperty(CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME,

ignore.toString());

}

}

打印日志-加载的资源

Banner printedBanner = printBanner(environment);

根据不同的WebApplicationType创建Context

context = createApplicationContext();

3.4 refreshContext

支持定制刷新

/**

* Register a shutdown hook with the JVM runtime, closing this context

* on JVM shutdown unless it has already been closed at that time.

* <p>This method can be called multiple times. Only one shutdown hook

* (at max) will be registered for each context instance.

* @see java.lang.Runtime#addShutdownHook

* @see #close()

*/

void registerShutdownHook();

3.5 afterRefresh

刷新后的实现方法暂未实现

/**

* Called after the context has been refreshed.

* @param context the application context

* @param args the application arguments

*/

protected void afterRefresh(ConfigurableApplicationContext context,

ApplicationArguments args) {

}

3.6 listeners.started(context);

到此为止, Spring Application的环境和资源都加载完毕了; 发布应用上下文启动完成事件; 执行所有 Runner 运行器 - 执行所有 ApplicationRunner 和 CommandLineRunner 这两种运行器

// 启动

callRunners(context, applicationArguments);

3.7 listeners.running(context);

触发所有 SpringApplicationRunListener 监听器的 running 事件方法

希望对你有帮助

如何在java程序中获取当前程序所在的目录?

Properties properties = System.getProperties();

System.out.println(properties.getProperty("user.dir"));

J2EE中如何使用SQLSERVER数据库的语句?

经过归纳得出J2EE sqlserver 连接数据库的三种配置:

一、连接池方式:

1、连接迟3个包+sqlserver驱动包复制到tomcat/common/lib

2、配置tomcat/conf/context.xml,注意2000和2005 驱动名字和路径

[xhtml] view plaincopyprint?

<Resource name="jdbc/pubs"

auth="Container" type="javax.sql.DataSource" maxActive="100"

maxIdle="30" maxWait="10000" username="sa" password="120010"

driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books"/>

[xhtml] view plaincopyprint?

<Resource name="jdbc/pubs"

auth="Container" type="javax.sql.DataSource" maxActive="100"

maxIdle="30" maxWait="10000" username="sa" password="120010"

driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books"/>

[java] view plaincopyprint?

//2000:

driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books"/>

//2005:

driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

url="jdbc:sqlserver://localhost:1433;DatabaseName=books"/>

[java] view plaincopyprint?

//2000:

driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books"/>

//2005:

driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

url="jdbc:sqlserver://localhost:1433;DatabaseName=books"/>

3、在工程web.xml添加节点

[c-sharp] view plaincopyprint?

<resource-ref>

<res-ref-name>jdbc/pubs</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

[c-sharp] view plaincopyprint?

<resource-ref>

<res-ref-name>jdbc/pubs</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

4、得到连接的方法内导如以下几个包:

[c-sharp] view plaincopyprint?

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.sql.DataSource;

// 得到Connection对象的方法

public static Connection getConnection(){

try {

Context ic = new InitialContext();

DataSource source = (DataSource)ic.lookup

("java:comp/env/jdbc/bbs");

con = source.getConnection();

}catch(NamingException ex){

ex.printStackTrace();

}catch(SQLException ex){

ex.printStackTrace();

}

return con;

}

[c-sharp] view plaincopyprint?

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.sql.DataSource;

// 得到Connection对象的方法

public static Connection getConnection(){

try {

Context ic = new InitialContext();

DataSource source = (DataSource)ic.lookup

("java:comp/env/jdbc/bbs");

con = source.getConnection();

}catch(NamingException ex){

ex.printStackTrace();

}catch(SQLException ex){

ex.printStackTrace();

}

return con;

}

================================================================================

二、读取属性文件方式

[java] view plaincopyprint?

*.properties文件

driverName=com.microsoft.sqlserver.jdbc.SQLServerDriver

url=jdbc:sqlserver://localhost:1433;DatabaseName=books

user=sa

password=123

//读取*.properties文件的类

import java.io.InputStream;

import java.util.Properties;

public final class Env extends Properties {

private static Env instance;

public static Env getInstance(){

if(instance != null){

return instance;

}else{

makeInstance();

return instance;

}

}

//synchronized 同步方法,保证同一时间只能被一个用户调用

private static synchronized void makeInstance(){

if(instance == null){

instance = new Env();

}

}

private Env(){

InputStream is =getClass().getResourceAsStream("db.properties");//配置文件位置

try{

load(is);

}catch(Exception ex){

System.err.println("请确认读取的文件是否存在!");

}

}

//测试连接是否成功方法方法

public static void main(String[] args) {

System.out.println(getInstance().getProperty("driverName"));

}

}

[java] view plaincopyprint?

*.properties文件

driverName=com.microsoft.sqlserver.jdbc.SQLServerDriver

url=jdbc:sqlserver://localhost:1433;DatabaseName=books

user=sa

password=123

//读取*.properties文件的类

import java.io.InputStream;

import java.util.Properties;

public final class Env extends Properties {

private static Env instance;

public static Env getInstance(){

if(instance != null){

return instance;

}else{

makeInstance();

return instance;

}

}

//synchronized 同步方法,保证同一时间只能被一个用户调用

private static synchronized void makeInstance(){

if(instance == null){

instance = new Env();

}

}

private Env(){

InputStream is =getClass().getResourceAsStream("db.properties");//配置文件位置

try{

load(is);

}catch(Exception ex){

System.err.println("请确认读取的文件是否存在!");

}

}

//测试连接是否成功方法方法

public static void main(String[] args) {

System.out.println(getInstance().getProperty("driverName"));

}

}

注意类的调用:譬如String url = Env.getInstance().getProperties("url");就能得到相应

的字符窜

驱动driverName,用户user, 密码password获取方式同上

==========================================================

三、读取xml文件中的节点

首先报连接池包3个和1个数据库驱动包复制到工程下WEB-INF/lib中

1、工程下的web.xml要添加以下节点:

[xhtml] view plaincopyprint?

<context-param>

<param-name>driverName</param-name>

<param-value>com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>

</context-param>

<context-param>

<param-name>url</param-name>

<param-value>jdbc:sqlserver://localhost:1433;DatabaseName=bbs</param-value>

</context-param>

<context-param>

<param-name>userName</param-name>

<param-value>sa</param-value>

</context-param>

<context-param>

<param-name>passWord</param-name>

<param-value>123</param-value>

</context-param>

[xhtml] view plaincopyprint?

<context-param>

<param-name>driverName</param-name>

<param-value>com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>

</context-param>

<context-param>

<param-name>url</param-name>

<param-value>jdbc:sqlserver://localhost:1433;DatabaseName=bbs</param-value>

</context-param>

<context-param>

<param-name>userName</param-name>

<param-value>sa</param-value>

</context-param>

<context-param>

<param-name>passWord</param-name>

<param-value>123</param-value>

</context-param>

2、新建一个普通类继承Httpservlet类,并实现ServletContextListener监听接口,如下:

[c-sharp] view plaincopyprint?

import java.sql.Connection;

import java.sql.ResultSet;

import javax.servlet.ServletContext;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

import javax.servlet.http.HttpServlet;

public class ContextListener extends HttpServlet implements ServletContextListener {

/**

* 销毁servlet

*/

public void contextDestroyed(ServletContextEvent sc) {

}

/**

* 初始化

*/

public void contextInitialized(ServletContextEvent sc) {

System.out.println("开启服务:");

ServletContext servletContext = sc.getServletContext();

String driverName = servletContext.getInitParamete("driverName");

String url = servletContext.getInitParameter("url");

String userName = servletContext.getInitParameter("userName");

String passWord = servletContext.getInitParameter("passWord");

BaseDAO.setDriverName(driverName);

BaseDAO.setUrl(url);

BaseDAO.setUser(userName);

BaseDAO.setPassword(passWord);

}

}

[c-sharp] view plaincopyprint?

import java.sql.Connection;

import java.sql.ResultSet;

import javax.servlet.ServletContext;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

import javax.servlet.http.HttpServlet;

public class ContextListener extends HttpServlet implements ServletContextListener {

/**

* 销毁servlet

*/

public void contextDestroyed(ServletContextEvent sc) {

}

/**

* 初始化

*/

public void contextInitialized(ServletContextEvent sc) {

System.out.println("开启服务:");

ServletContext servletContext = sc.getServletContext();

String driverName = servletContext.getInitParamete("driverName");

String url = servletContext.getInitParameter("url");

String userName = servletContext.getInitParameter("userName");

String passWord = servletContext.getInitParameter("passWord");

BaseDAO.setDriverName(driverName);

BaseDAO.setUrl(url);

BaseDAO.setUser(userName);

BaseDAO.setPassword(passWord);

}

}

3、在公共类BaseDao中

[java] view plaincopyprint?

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource; //连接池要到包

/*

* 获取数据库连接

*/

public class BaseDAO {

private static Connection con;

private static String driverName;

private static String url;

private static String userName;

private static String passWord;

//获取连接对象Connection

public static Connection getConnection(){

BasicDataSource dataSource = new BasicDataSource();

dataSource.setDriverClassName(driverName);

dataSource.setUrl(url);

dataSource.setUsername(userName);

dataSource.setPassword(passWord);

try{

con = dataSource.getConnection();

} catch(SQLException ex) {

ex.printStackTrace();

}

return con;

}

/*

* 配置:从web.xml

*/

//驱动名称

public static String getDriverName() {

return getDriverName();

}

public static void setDriverName(String driverName) {

BaseDAO.driverName = driverName;

}

//URL

public static String getUrl(){

return getUrl();

}

public static void setUrl(String url) {

BaseDAO.url = url;

}

//用户名

public static String getUser(){

return getUser();

}

public static void setUser(String userName) {

BaseDAO.userName = userName;

}

//密码

public static String getPassWord(){

return getPassWord();

}

public static void setPassword(String passWord) {

BaseDAO.passWord = passWord;

}

}

[java] view plaincopyprint?

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource; //连接池要到包

/*

* 获取数据库连接

*/

public class BaseDAO {

private static Connection con;

private static String driverName;

private static String url;

private static String userName;

private static String passWord;

//获取连接对象Connection

public static Connection getConnection(){

BasicDataSource dataSource = new BasicDataSource();

dataSource.setDriverClassName(driverName);

dataSource.setUrl(url);

dataSource.setUsername(userName);

dataSource.setPassword(passWord);

try{

con = dataSource.getConnection();

} catch(SQLException ex) {

ex.printStackTrace();

}

return con;

}

/*

* 配置:从web.xml

*/

//驱动名称

public static String getDriverName() {

return getDriverName();

}

public static void setDriverName(String driverName) {

BaseDAO.driverName = driverName;

}

//URL

public static String getUrl(){

return getUrl();

}

public static void setUrl(String url) {

BaseDAO.url = url;

}

//用户名

public static String getUser(){

return getUser();

}

public static void setUser(String userName) {

BaseDAO.userName = userName;

}

//密码

public static String getPassWord(){

return getPassWord();

}

public static void setPassword(String passWord) {

BaseDAO.passWord = passWord;

}

}

新建用户变量名怎么设?

用户可以自己根据需要设定一个变量名,但是需要注意以下几点:1. 变量名需要具有可读性,便于自己和别人理解。2. 变量名不能含有空格或其他非法字符。3. 变量名需要与所代表的数据内容相符,避免产生混淆和歧义。在设置变量名的过程中,可以根据需要结合英文字符、数字或其他字符来构成有意义的变量名,例如“age”、“name”等。同时,也可以根据需要在变量名中使用下划线或驼峰命名法来区分不同的单词或词组。总之,需要根据具体情况合理设定变量名,以方便程序的编写和使用。

发表评论

快捷回复: 表情:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog
评论列表 (暂无评论,108人围观)

还没有评论,来说两句吧...