前提情要:

培训的时候都没讲过,也是书上看到过这么个东西,进公司干外包的第二个项目就用了这个鬼东西

自学也不是没尝试过实现,结果各种失败,还找不到问题所在,索性不写了

JNDI实现参考:

目前参考这篇博客是有效且成功的:

https://www.cnblogs.com/zhchoutai/p/7389089.html

存在的环境问题(踩过的烂坑):

1、Tomcat版本只能在8版本以下

2、MySQL驱动Jar包 只允许在5版本以下 (目前公司用的5.1版本,可能往上5.7版本也不支持了)

3、关于JNDI配置描述的正确方法(配置文件存放位置众说纷纭。。。)

实现操作:

Tomcat官方文档有描述说是有自带数据源连接池

但是没驱动,道理就是Tomcat也不知道你要连上什么厂商的数据库,Oracle? MySQL? SqlServer?

所以这东西你得自己弄

在Tomcat的Lib目录下放上这个驱动包

D:\Server\apache-tomcat-8.5.69\lib\mysql-connector-java-5.1.35.jar

然后配置连接描述:

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context> <!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
--> <Resource
name="jndiTesting"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root" password="TencentCloud@mysql5.7.18-dzz!1376"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://cdb-6cmot19i.cd.tencentcdb.com:10000/jmcwechat_cyc"/>
</Context>

注意 name,auth 这两个东西不能搞错

这个文件的位置在:

D:\Server\apache-tomcat-8.5.69\conf\context.xml

然后用IDEA随便搭建一个JavaWeb项目,就是普通项目,都不需要Maven构建的那种

在web.xml里面配置JNDI信息

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"> <resource-ref>
<description>DB Connection</description>
<res-ref-name>jndiTesting</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</web-app>

文件位置(在项目里面可以找到):

C:\Users\Administrator\IdeaProjects\JndiTesting\web\WEB-INF\web.xml

检查是否连接成功:

在首页index.jsp编写 连接的嵌入代码

<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2021/7/19
Time: 18:48
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*,javax.sql.*,javax.naming.*" %>

<html>
<head>
<title>$Title$</title>
</head>
<body>
$END$ <%
Connection conn = null;
try {
//初始化查找命名空间
Context ctx = new InitialContext();
//InitialContext ctx = new InitialContext();亦可
//找到DataSource,对名称进行定位java:comp/env是必须加的,后面跟你的DataSource名
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jndiTesting");
//取出连接
conn = ds.getConnection();
System.out.println("connection pool connected !!");
} catch (NamingException e) {
System.out.println(e.getMessage());
} catch (SQLException e) {
e.printStackTrace();
}finally {
//注意不是关闭,是放回连接池.
conn.close();
}
%>

</body>
</html>

开启项目后,控制台成功打印:

D:\Server\apache-tomcat-8.5.69\bin\catalina.bat run
[2021-07-19 06:54:32,504] Artifact JndiTesting:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2"
Using CATALINA_HOME: "D:\Server\apache-tomcat-8.5.69"
Using CATALINA_TMPDIR: "D:\Server\apache-tomcat-8.5.69\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_291"
Using CLASSPATH: "D:\Server\apache-tomcat-8.5.69\bin\bootstrap.jar;D:\Server\apache-tomcat-8.5.69\bin\tomcat-juli.jar"
Using CATALINA_OPTS: ""
19-Jul-2021 18:54:33.185 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.鏈嶅姟鍣ㄧ増鏈�: Apache Tomcat/8.5.69
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏈嶅姟鍣ㄦ瀯寤�: Jun 30 2021 18:00:00 UTC
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏈嶅姟鍣ㄧ増鏈彿: 8.5.69.0
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鎿嶄綔绯荤粺鍚嶇О: Windows 10
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.鐗堟湰: 10.0
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏋舵瀯: amd64
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 鐜鍙橀噺: C:\Program Files\Java\jdk1.8.0_291\jre
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java铏氭嫙鏈虹増鏈�: 1.8.0_291-b10
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.渚涘簲鍟�: Oracle Corporation
19-Jul-2021 18:54:33.186 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: D:\Server\apache-tomcat-8.5.69
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.util.logging.config.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2\conf\logging.properties
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote=
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.port=1099
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.ssl=false
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.password.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2\jmxremote.password
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.access.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2\jmxremote.access
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.rmi.server.hostname=127.0.0.1
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djdk.tls.ephemeralDHKeySize=2048
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dignore.endorsed.dirs=
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcatalina.base=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\05f72586-ccf4-4015-b51e-2d50f0d989f2
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcatalina.home=D:\Server\apache-tomcat-8.5.69
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.io.tmpdir=D:\Server\apache-tomcat-8.5.69\temp
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 浣跨敤APR鐗堟湰[1.7.0]鍔犺浇浜嗗熀浜嶢PR鐨凙pache Tomcat鏈満搴揫1.2.30]銆�
19-Jul-2021 18:54:33.187 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR鍔熻兘锛欼Pv6[true]銆乻endfile[true]銆乤ccept filters[false]銆乺andom[true]銆�
19-Jul-2021 18:54:33.188 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL閰嶇疆锛歶seAprConnector[false]锛寀seOpenSSL[true]
19-Jul-2021 18:54:33.190 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL鎴愬姛鍒濆鍖� [OpenSSL 1.1.1k 25 Mar 2021]
19-Jul-2021 18:54:33.276 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init 鍒濆鍖栧崗璁鐞嗗櫒 ["http-nio-8080"]
19-Jul-2021 18:54:33.286 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
19-Jul-2021 18:54:33.295 淇℃伅 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 315 ms
19-Jul-2021 18:54:33.318 淇℃伅 [main] org.apache.catalina.core.StandardService.startInternal 姝e湪鍚姩鏈嶅姟[Catalina]
19-Jul-2021 18:54:33.318 淇℃伅 [main] org.apache.catalina.core.StandardEngine.startInternal 姝e湪鍚姩 Servlet 寮曟搸锛歔Apache Tomcat/8.5.69]
19-Jul-2021 18:54:33.323 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start 寮�濮嬪崗璁鐞嗗彞鏌刐"http-nio-8080"]
19-Jul-2021 18:54:33.330 淇℃伅 [main] org.apache.catalina.startup.Catalina.start Server startup in 34 ms
Connected to server
[2021-07-19 06:54:33,546] Artifact JndiTesting:war exploded: Artifact is being deployed, please wait...
19-Jul-2021 18:54:33.656 璀﹀憡 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion 鏈煡鐗堟湰瀛楃涓� [4.0]銆傚皢浣跨敤榛樿鐗堟湰銆�
19-Jul-2021 18:54:33.809 璀﹀憡 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = jndiTesting Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored.
19-Jul-2021 18:54:33.809 璀﹀憡 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = jndiTesting Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored.
19-Jul-2021 18:54:33.828 淇℃伅 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars 鑷冲皯鏈変竴涓狫AR琚壂鎻忕敤浜嶵LD浣嗗皻鏈寘鍚玊LD銆� 涓烘璁板綍鍣ㄥ惎鐢ㄨ皟璇曟棩蹇楄褰曪紝浠ヨ幏鍙栧凡鎵弿浣嗘湭鍦ㄥ叾涓壘鍒癟LD鐨勫畬鏁碕AR鍒楄〃銆� 鍦ㄦ壂鎻忔湡闂磋烦杩囦笉闇�瑕佺殑JAR鍙互缂╃煭鍚姩鏃堕棿鍜孞SP缂栬瘧鏃堕棿銆�
[2021-07-19 06:54:33,856] Artifact JndiTesting:war exploded: Artifact is deployed successfully
[2021-07-19 06:54:33,856] Artifact JndiTesting:war exploded: Deploy took 310 milliseconds
connection pool connected !!
connection pool connected !!
connection pool connected !!
19-Jul-2021 18:54:43.329 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 鎶妛eb 搴旂敤绋嬪簭閮ㄧ讲鍒扮洰褰� [D:\Server\apache-tomcat-8.5.69\webapps\manager]
19-Jul-2021 18:54:43.402 璀﹀憡 [localhost-startStop-1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = jndiTesting Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored.
19-Jul-2021 18:54:43.402 璀﹀憡 [localhost-startStop-1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = jndiTesting Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored.
19-Jul-2021 18:54:43.404 淇℃伅 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars 鑷冲皯鏈変竴涓狫AR琚壂鎻忕敤浜嶵LD浣嗗皻鏈寘鍚玊LD銆� 涓烘璁板綍鍣ㄥ惎鐢ㄨ皟璇曟棩蹇楄褰曪紝浠ヨ幏鍙栧凡鎵弿浣嗘湭鍦ㄥ叾涓壘鍒癟LD鐨勫畬鏁碕AR鍒楄〃銆� 鍦ㄦ壂鎻忔湡闂磋烦杩囦笉闇�瑕佺殑JAR鍙互缂╃煭鍚姩鏃堕棿鍜孞SP缂栬瘧鏃堕棿銆�
19-Jul-2021 18:54:43.409 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web搴旂敤绋嬪簭鐩綍[D:\Server\apache-tomcat-8.5.69\webapps\manager]鐨勯儴缃插凡鍦╗79]姣鍐呭畬鎴�

不放心还写了个Servlet查询测试了下,没问题的

package cn.dzz.util;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException; public class JndiUtil { private JndiUtil(){} private static DataSource dataSource; static {
try {
Context ctx = new InitialContext();
Object lookup = ctx.lookup("java:comp/env/jndiTesting");
dataSource = (DataSource) lookup;
} catch (NamingException e) {
e.printStackTrace();
}
} public static Connection getConnection() {
try {
return dataSource.getConnection();
} catch (SQLException throwables) {
throwables.printStackTrace();
return null;
}
}
}

HelloServlet,这个是web.xml的4.0协议,可以直接写注解处理了

package cn.dzz.servlet;

import cn.dzz.util.JndiUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; @WebServlet("/hello")
public class HelloServlet extends HttpServlet { @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Connection connection = JndiUtil.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM tt_wechat_org"); ResultSet resultSet = preparedStatement.executeQuery(); ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); // 元数据对象获取总共的记录的列数 ArrayList<Object> objects = new ArrayList<>();
while (resultSet.next()){ // 判断是否还有下一个记录行
Map<Integer,Object> map = new HashMap<Integer, Object>(); //作为每一行的记录 for (int i = 0; i < columnCount ; i++) { // 通过遍历记录列数,获取每个列的值
Object object = resultSet.getObject(i + 1);
map.put(i,object); // 装入每个字段的值
}
objects.add(map); // 遍历多少,装载多少个记录
}
resultSet.close(); // 资源释放 System.out.println(objects);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
}

题外话:

这是简单的基础JNDI连接方式

在项目里面Spring框架还做了JNDI的支持

【Java】JNDI实现的更多相关文章

  1. Java JNDI 学习

    一.概念: 1.JNDI(JavaNaming and Directory Interface,Java命名和目录接口)是SUN公司提供的一种标准的Java命名系统接口,JNDI提供统一的客户端API ...

  2. Java JNDI Datasource HOW-TO Problem

    在开发JAVA的时候发生了点问题,解决方案记录一下,在这里http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto. ...

  3. Java Naming and Directory Interface (JNDI) Java 命名和目录接口

    https://www.oracle.com/technetwork/java/jndi/index.html Lesson: Overview of JNDI (The Java™ Tutorial ...

  4. Java之JNDI注入

    Java之JNDI注入 About JNDI 0x01 简介 JNDI(Java Naming and Directory Interface)是SUN公司提供的一种标准的Java命名系统接口,JND ...

  5. 用JAVA 查询 Active Directory(AD)

    Required Details LDAP address (For e.g.: myjeeva.com or IP of the Domain Controller/Global Catalog[G ...

  6. JNDI support differences between Tibco EMS and ActiveMQ

    Introduction Recently our team was working on Veracity Quick Start sprint, when I was trying to migr ...

  7. java语言体系的技术简介之JSP、Servlet、JDBC、JavaBean(Application)

    转自:https://zhangkunnan.iteye.com/blog/2040462 前言 Java语言 Java语言体系比较庞大,包括多个模块.从WEB项目应用角度讲有JSP.Servlet. ...

  8. JNDI With RMI

    JNDI With RMI JNDI with RMI JNDI即Java Naming and Directory Interface(JAVA命名和目录接口),jndi类似于一个索引中心,允许客户 ...

  9. 2.一个EJB的小Demo

    新建一个java普通项目即可 这里用到了Jboss,需要安装Jboss,然后进入jboss-4.2.3.GA\client目录,拷贝所有的jar包到本项目的lib下. 3个接口分别如下所示: publ ...

  10. 1.认识EJB

    什么是EJB?1. Enterprice JavaBeans(EJB)是一个用于分布式业务应用的标准服务端组件模型. . 采用EJB架构编写的应用是可伸的.事务性的.多用户安全的. . 采用EJB编写 ...

随机推荐

  1. vue3拉取代码install 报错 npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: npm ERR! Found: vue@3.2.31

    先看报错 说明安装的包和现有的包已经冲突了版本不一致 我们先试一下npm install @vue/cli -- force然后再试一下npm install @vue/cli --legacy-pe ...

  2. 使用命令行(powershell)压缩(7Z RAR)指定日期文件

    使用命令行(powershell)压缩(7Z RAR)指定日期文件,powershell ,7z. WINDOWS命令行是无法按时间过滤文件的,我们通过powershell 里的Get-ChildIt ...

  3. error pulling image configuration: Get https://eastasia.data.mcr.microsoft.com -- net/http: TLS handshake timeout

    error pulling image configuration: Get https://eastasia.data.mcr.microsoft.com/b29889755b1f4e46b6b44 ...

  4. 网络诊断工具traceroute的使用

    在 Linux 系统中,traceroute 是一个网络诊断工具,用于确定数据包从你的计算机到目标主机(如一个网站或远程服务器)所经过的路由路径. 如果你的系统中没有安装 traceroute,你可以 ...

  5. vitepress使用createContentLoader时遇到["vitepress" resolved to an ESM file. ESM file cannot be loaded by `require`.]报错

    在使用vitepress构建一个所有博客的概览页的时候,使用到了createContentLoader这个api,但是在index.data.ts中定义并导出后,在md文件中调用遇到了下面这个问题: ...

  6. Python数据类型(数字,字符串,[列表],(元组),{字典:字典值},{列表,列表2})

    Python数据类型(数字,字符串,[列表],(元组),{字典:字典值},{列表,列表2}) # 1. # Python3 数字(Number) # Python 数字数据类型用于存储数值. # 数据 ...

  7. base64图片文件上传OSS,下载OSS图片转换为InputStream,文件转base64,base64转文件工具类

    base64图片文件上传OSS,下载OSS图片转换为InputStream,文件转base64,base64转文件工具类 OSSUtils.java public class OSSUtils { p ...

  8. 教您在79元ARM平台实现H.265视频解码

    什么是H.265视频编解码? (1)什么是H.265 H.265,也被称为HEVC(HighEfficiency Video Coding),作为H.264的继任者,提供了更好的视频压缩和更高的视频质 ...

  9. Windows Android 子系统(WSA)安装

    除了Linux子系统WSL,微软还提供了安卓子系统WSA.不过对国内好像不太友好,安装也不方便. 这里说一下我的安装方法,但是可能时效性很强,现在是2022-01-20,如果日期离得太远可能不好使. ...

  10. Java常见的加密方式

    前言 传说在古罗马时代,发生了一次大战.正当敌方部队向罗马城推进时,古罗马皇帝凯撒向前线司令官发出了一封密信:VWRS WUDIILF.这封密信被敌方情报人员翻遍英文字典,也查不出这两个词的意思. 此 ...