javaweb项目接入CAS单点认证(含自身系统的三员过滤)

news2024/11/24 15:52:07

一、搭建cas server
1.下载war包
在这里插入图片描述
2.打开cmd窗口执行以下命令,命令如下(指定ip):

keytool -genkey -v -alias casbm -keyalg RSA -keystore D:\cas\keystore\casbm.keystore -ext SAN=IP:192.168.2.166 

3.我们生成秘钥库后需要从秘钥库中导出证书,打开cmd窗口,命令如下:

keytool -export -trustcacerts -alias casbm -file D:/cas/keystore/casbm.cer -keystore D:/cas/keystore/casbm.keystore

4.我们从秘钥库导出证书后需要将证书导入到JDK证书库中,打开cmd窗口,命令如下,其中最后的路径为你本地jdk的路径,要确保该路径正确(此处密码不是自己设置的,是默认密码:changeit):
keytool -import -trustcacerts -alias casbm -file D:/cas/keystore/casbm.cer -keystore “D:/Configure/java/java8/jre/lib/security/cacerts”
5.由于cas需要https协议访问,所以我们要配置tomcat也支持https协议,我们找到我们的tomcat的server.xml文件,加入如下配置:

<Connector port=8443” protocol=org.apache.coyote.http11.Http11NioProtocol”

maxThreads=150SSLEnabled=true” scheme=“https” secure=true”
clientAuth=false” sslProtocol=TLS” keystoreFile=D:\cas\keystore\casbm.keystore” keystorePass=123456/>

6.将之前下载的cas包放入tomcat中启动,首先将war包放入tomcat的webapps下,改名为cas,启动tomcat
7.启动完成后我们访问登录页面验证是否启动成功,访问地址如下,用户名为:casuser 密码为:Mellon:
https://localhost:8443/cas
8.用户名密码是在application.properties配置文件中指定的(需要删除原cas.war,避免覆盖)

##
# CAS Authentication Credentials
#
cas.authn.accept.users=dagly::most123456789
#cas.authn.jdbc.query[0].url=jdbc:kingbase8://192.168.2.166:54321/WANGLIAN

#cas.authn.jdbc.query[0].user=WANGLIAN

#cas.authn.jdbc.query[0].password=manager123

#cas.authn.jdbc.query[0].sql=select * from hdrole where login_name = ?

#cas.authn.jdbc.query[0].fieldPassword=password

#cas.authn.jdbc.query[0].driverClass=com.kingbase8.Driver

#cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT

#cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=GBK
#MD5加密策略

#cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5

#是否开启json识别功能,默认为false
cas.serviceRegistry.initFromJson=true
#忽略https安全协议,使用 HTTP 协议
cas.tgc.secure=false
cas.logout.followServiceRedirects=true

9.使用数据库连接时加入jar:

cas-server-support-jdbc-5.3.1.jar

cas-server-support-jdbc-drivers-5.3.1.jar

cas-server-support-jdbc-authentication-5.3.1.jar

connector-java-5.1.34_1.jar

二、接入CAS 的client
1.修改tomcat的server.xml引入证书:,项目中引入cas-client-core-3.6.4.jar

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" keystoreFile="D:\cas\keystore\casbm.keystore" keystorePass="123456"/>

2.在web.xml中加入配置(删掉注释,此处为了解释):

//单点登出的listener
<listener>
    <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
  </listener>
  //单点登出过滤器
  <filter>
    <filter-name>CAS Single Sign Out Filter</filter-name>
    <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>CAS Single Sign Out Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  //自定义的顶层filer,用于处理请求
  <filter>
    <filter-name>FetchCasTicketFilter</filter-name>
    <filter-class>com.hidy.auth.servlet.FetchCasTicketFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>FetchCasTicketFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  //认证过滤器,此处重写,用官方的无法配置不过滤的路径
  <filter>
    <filter-name>CASFilter</filter-name>
    <filter-class>com.hidy.auth.servlet.AuthenticationFilter</filter-class>
    <init-param>
      <param-name>casServerLoginUrl</param-name>
      <param-value>https://192.168.2.166:8443/cas/login</param-value>//CAS server登录页
    </init-param>
    <init-param>
      <param-name>serverName</param-name>
      <param-value>http://192.168.2.166:8080/</param-value>//项目地址
    </init-param>
    <init-param>
      <param-name>ignorePattern</param-name>
      <param-value>/defaultpsy.*|/theme/*|/LoginServlet|/images/*|/TransInterface</param-value>//
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CASFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>CAS Validation Filter</filter-name>//认证拦截器
    <filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
    <init-param>
      <param-name>targetBeanName</param-name>
      <param-value>loginSinglePointScoreBp</param-value>
    </init-param>
    <init-param>
      <param-name>casServerUrlPrefix</param-name>
      <param-value>https://192.168.2.166:8443/cas</param-value>
    </init-param>
    <init-param>
      <param-name>serverName</param-name>
      <param-value>http://192.168.2.166:8080/</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CAS Validation Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  //处理request,能够用request.getRemoteUser()获取当前登录人
  <filter>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  //单点的登录servlet(即对原来的登录servlet复制,逻辑进行修改,原来的用于三员登录)
  <servlet>
    <servlet-name>LoginServletCas</servlet-name>
    <servlet-class>com.hidy.auth.servlet.LoginServletCas</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServletCas</servlet-name>
    <url-pattern>/LoginServletCas</url-pattern>
  </servlet-mapping>

3.FetchCasTicketFilter代码,顶级过滤器

package com.hidy.auth.servlet;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jasig.cas.client.util.CommonUtils;

import com.hidy.hdoa6.util.StaticData;

import org.jasig.cas.client.util.CommonUtils;
 
 
public class FetchCasTicketFilter implements Filter {
 
 
 
 
 @Override
 public void destroy() {
  // TODO Auto-generated method stub
 
 }
 
 @Override
 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
   throws IOException, ServletException {
	 
	 
  HttpServletRequest request = (HttpServletRequest) req;
  HttpServletResponse response=(HttpServletResponse) res;
  
  String path = request.getServletPath();
  Object id = request.getSession().getAttribute("UserID");
  String ticket = request.getParameter("ticket");
  
  String requestUri=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
  //对一些路径不拦截
  if(id == null && ticket==null && !(path.endsWith("defaultp.jsp") || path.endsWith(".js") || path.endsWith(".css") || path.endsWith("/LoginServlet")|| path.endsWith("/LoginServletCas")|| path.endsWith("/defaultpsy.jsp")|| path.endsWith(".png")||path.endsWith("/TransInterface"))) {
	  String result = "<script>top.window.location.href='"+StaticData.HD_CA_URI+"/login?service="+requestUri+"'</script>";
	  response.getWriter().print(result);
	  response.getWriter().close();
  }else {
  //获取cas的ticket,看cas server配置的规则,如果是认证完即失效,则此处可以不写
	  String queryString = request.getQueryString();
	  
	  if(queryString != null && queryString.contains("ticket")){
		  Cookie cookie=new Cookie("ticket",queryString.substring(queryString.indexOf("=") + 1) );
		  cookie.setMaxAge(Integer.MAX_VALUE);
		  //将Cookie加到response中
		  response.addCookie(cookie);
	  }
	  chain.doFilter(req, res);
  }
  
  
 }
 
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
  
 }
 

 
}

4.AuthenticationFilter代码(不一定一致,当前用的cas client core3.6.4,其他版本反编译后修改逻辑,主要是对不拦截路径的放行)

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.jasig.cas.client.Protocol;
import org.jasig.cas.client.authentication.AuthenticationRedirectStrategy;
import org.jasig.cas.client.authentication.ContainsPatternUrlPatternMatcherStrategy;
import org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy;
import org.jasig.cas.client.authentication.DefaultGatewayResolverImpl;
import org.jasig.cas.client.authentication.EntireRegionRegexUrlPatternMatcherStrategy;
import org.jasig.cas.client.authentication.ExactUrlPatternMatcherStrategy;
import org.jasig.cas.client.authentication.GatewayResolver;
import org.jasig.cas.client.authentication.RegexUrlPatternMatcherStrategy;
import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy;
import org.jasig.cas.client.configuration.ConfigurationKey;
import org.jasig.cas.client.configuration.ConfigurationKeys;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.ReflectUtils;
import org.jasig.cas.client.validation.Assertion;
public class AuthenticationFilter extends AbstractCasFilter {
    private String casServerLoginUrl;
    private boolean renew;
    private boolean gateway;
    private String method;
    private GatewayResolver gatewayStorage;
    private AuthenticationRedirectStrategy authenticationRedirectStrategy;
    private UrlPatternMatcherStrategy ignoreUrlPatternMatcherStrategyClass;
    private static final Map<String, Class<? extends UrlPatternMatcherStrategy>> PATTERN_MATCHER_TYPES = new HashMap();

    private String excludePaths;  
    
    public AuthenticationFilter() {
        this(Protocol.CAS2);
    }

    protected AuthenticationFilter(Protocol protocol) {
        super(protocol);
        this.renew = false;
        this.gateway = false;
        this.gatewayStorage = new DefaultGatewayResolverImpl();
        this.authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
        this.ignoreUrlPatternMatcherStrategyClass = null;
    }

    protected void initInternal(FilterConfig filterConfig) throws ServletException {
        if (!this.isIgnoreInitConfiguration()) {
            super.initInternal(filterConfig);
            String loginUrl = this.getString(ConfigurationKeys.CAS_SERVER_LOGIN_URL);
            if (loginUrl != null) {
                this.setCasServerLoginUrl(loginUrl);
            } else {
                this.setCasServerUrlPrefix(this.getString(ConfigurationKeys.CAS_SERVER_URL_PREFIX));
            }

            this.setRenew(this.getBoolean(ConfigurationKeys.RENEW));
            this.setGateway(this.getBoolean(ConfigurationKeys.GATEWAY));
            this.setMethod(this.getString(ConfigurationKeys.METHOD));
            String ignorePattern = this.getString(ConfigurationKeys.IGNORE_PATTERN);
            String ignoreUrlPatternType = this.getString(ConfigurationKeys.IGNORE_URL_PATTERN_TYPE);
            Class gatewayStorageClass;
            if (ignorePattern != null) {
                gatewayStorageClass = (Class)PATTERN_MATCHER_TYPES.get(ignoreUrlPatternType);
                if (gatewayStorageClass != null) {
                    this.ignoreUrlPatternMatcherStrategyClass = (UrlPatternMatcherStrategy)ReflectUtils.newInstance(gatewayStorageClass.getName(), new Object[0]);
                } else {
                    try {
                        this.logger.trace("Assuming {} is a qualified class name...", ignoreUrlPatternType);
                        this.ignoreUrlPatternMatcherStrategyClass = (UrlPatternMatcherStrategy)ReflectUtils.newInstance(ignoreUrlPatternType, new Object[0]);
                    } catch (IllegalArgumentException var7) {
                        this.logger.error("Could not instantiate class [{}]", ignoreUrlPatternType, var7);
                    }
                }

                if (this.ignoreUrlPatternMatcherStrategyClass != null) {
                    this.ignoreUrlPatternMatcherStrategyClass.setPattern(ignorePattern);
                }
            }

            gatewayStorageClass = this.getClass(ConfigurationKeys.GATEWAY_STORAGE_CLASS);
            if (gatewayStorageClass != null) {
                this.setGatewayStorage((GatewayResolver)ReflectUtils.newInstance(gatewayStorageClass, new Object[0]));
            }

            Class<? extends AuthenticationRedirectStrategy> authenticationRedirectStrategyClass = this.getClass(ConfigurationKeys.AUTHENTICATION_REDIRECT_STRATEGY_CLASS);
            if (authenticationRedirectStrategyClass != null) {
                this.authenticationRedirectStrategy = (AuthenticationRedirectStrategy)ReflectUtils.newInstance(authenticationRedirectStrategyClass, new Object[0]);
            }
            
            excludePaths = this.getString(new ConfigurationKey("ignorePattern", (Object)null));
            excludePaths = excludePaths.trim();
        }

    }

    public void init() {
        super.init();
        String message = String.format("one of %s and %s must not be null.", ConfigurationKeys.CAS_SERVER_LOGIN_URL.getName(), ConfigurationKeys.CAS_SERVER_URL_PREFIX.getName());
        CommonUtils.assertNotNull(this.casServerLoginUrl, message);
    }

    public final void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest)servletRequest;
        HttpServletResponse response = (HttpServletResponse)servletResponse;
//三员用户直接放行        if(null!=request.getSession().getAttribute("isXtgly")||null!=request.getSession().getAttribute("isAqbmy")||null!=request.getSession().getAttribute("isAqsjy")) {
    		filterChain.doFilter(request, response);
    		return;
    	}
        if (this.isRequestUrlExcluded(request)) {
            this.logger.debug("Request is ignored.");
            filterChain.doFilter(request, response);
            return;
        } else {
            HttpSession session = request.getSession(false);
            Assertion assertion = session != null ? (Assertion)session.getAttribute("_const_cas_assertion_") : null;
            if (assertion != null) {
                filterChain.doFilter(request, response);
            } else {
                String serviceUrl = this.constructServiceUrl(request, response);
                String ticket = this.retrieveTicketFromRequest(request);
                boolean wasGatewayed = this.gateway && this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);
                if (!CommonUtils.isNotBlank(ticket) && !wasGatewayed) {
                    this.logger.debug("no ticket and no assertion found");
                    String modifiedServiceUrl;
                    if (this.gateway) {
                        this.logger.debug("setting gateway attribute in session");
                        modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
                    } else {
                        modifiedServiceUrl = serviceUrl;
                    }

                    this.logger.debug("Constructed service url: {}", modifiedServiceUrl);
                    String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, this.getProtocol().getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway, this.method);
                    this.logger.debug("redirecting to \"{}\"", urlToRedirectTo);
                    this.authenticationRedirectStrategy.redirect(request, response, urlToRedirectTo);
                } else {
                    filterChain.doFilter(request, response);
                }
            }
        }
    }

    public final void setRenew(boolean renew) {
        this.renew = renew;
    }

    public final void setGateway(boolean gateway) {
        this.gateway = gateway;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public final void setCasServerUrlPrefix(String casServerUrlPrefix) {
        this.setCasServerLoginUrl(CommonUtils.addTrailingSlash(casServerUrlPrefix) + "login");
    }

    public final void setCasServerLoginUrl(String casServerLoginUrl) {
        this.casServerLoginUrl = casServerLoginUrl;
    }

    public final void setGatewayStorage(GatewayResolver gatewayStorage) {
        this.gatewayStorage = gatewayStorage;
    }
//自行修改代码
    private boolean isRequestUrlExcluded(HttpServletRequest request) {
        if (this.ignoreUrlPatternMatcherStrategyClass == null) {
            return false;
        } else {
            StringBuffer urlBuffer = request.getRequestURL();
            if (request.getQueryString() != null) {
                urlBuffer.append("?").append(request.getQueryString());
            }

            String requestUri = urlBuffer.toString();
            return this.ignoreUrlPatternMatcherStrategyClass.matches(requestUri);
        }
    }

    public final void setIgnoreUrlPatternMatcherStrategyClass(UrlPatternMatcherStrategy ignoreUrlPatternMatcherStrategyClass) {
        this.ignoreUrlPatternMatcherStrategyClass = ignoreUrlPatternMatcherStrategyClass;
    }

    static {
        PATTERN_MATCHER_TYPES.put("CONTAINS", ContainsPatternUrlPatternMatcherStrategy.class);
        PATTERN_MATCHER_TYPES.put("REGEX", RegexUrlPatternMatcherStrategy.class);
        PATTERN_MATCHER_TYPES.put("FULL_REGEX", EntireRegionRegexUrlPatternMatcherStrategy.class);
        PATTERN_MATCHER_TYPES.put("EXACT", ExactUrlPatternMatcherStrategy.class);
    }
}

5.登录页验证是否已经cas登录

	String user=request.getRemoteUser();
	String casloginflag="false";
	if(!"".equals(user)&&null!=user){//已经在cas登录
		casloginflag="true";
	}
	为true是直接跳转到LoginServletCas

6.三员
复制一个登录页,登录servlet,不验证cas,只验证session中三员是否登录,此页面需要在web.xml中修改,放行此页面和相关servlet(包括上面AuthenticationFilter的逻辑处理)
参考资料:
CAS实现单点登录
自定义cas客户端核心过滤器AuthenticationFilter
其他

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/126505.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

D. Distinct Characters Queries(set维护)

Problem - 1234D - Codeforces 给你一个由小写拉丁字母组成的字符串s和对这个字符串的q个查询。 回顾一下&#xff0c;字符串s的子串s[l;r]就是字符串slsl1...sr。例如&#xff0c;"codeforces "的子串是 "code"、"force"、"f"、&quo…

spring6(概念;ioc详解,各种数据的注入方式)

第一章 启示录 一个普通的三层架构&#xff0c;不借助spring的情况下。需要程序员自己去new对象。 如果使用这种方式&#xff0c;那么代码上就把功能写死了&#xff0c;这时候需要更改一个数据库连接。这是时候数据交互层的代码就需要修改。这违背了OCP开闭原则。 1.1 OCP开闭…

Bert 得到中文词向量

通过bert中文预训练模型得到中文词向量和句向量&#xff0c;步骤如下&#xff1a; 下载 bert-base-chiese模型 只需下载以下三个文件&#xff0c;然后放到bert-base-chinese命名的文件夹中 得到中文词向量的代码如下 import torch from transformers import BertTokenizer,…

can8.0-基础知识

1、canopen协议概述 1.1对象字典 CANopen 协议采用了带有 16 位索引和 8 位子索引的对象字典,对象字典的结构如表 1.2 常用的通信对象 1) 网络管理对象 (NMT) 2) 服务数据对象 (SDO) 3) 过程数据对象 (PDO) 4) 同步对象 (SYNC) 5) 紧急报文 (EMCY) 1.3 通信对象…

PISR 数据库,区块链和大数据的下一个最佳结合

据集合。如今&#xff0c;在大数据时代&#xff0c;数据管理越来越受到重视&#xff0c;已经成为一项非常重要的资产。因此&#xff0c;数据安全也变得越来越重要&#xff0c;应该引起重视。尽管现有数据库可以满足单个公司的存储依赖性&#xff0c;但它们很难确保公司之间协作…

React学习03-基于脚手架的React应用

初始化脚手架 使用 npx 创建 npx create-react-app 项目名使用 npm install 创建 全局安装create-react-app包&#xff1a; npm install -g create-react-app创建脚手架&#xff1a; create-react-app 项目名npm 镜像 执行 create-react-app时&#xff0c;还会自动安装一…

C++程序员学习资料汇总

小白入门 计算机网络微课堂&#xff08;有字幕无背景音乐版&#xff09; 非常适合小白学习&#xff0c;没有废话&#xff0c;非常生动 《计算机是怎样跑起来的》 《程序是怎样跑起来的》 《网络是怎样连接的》 基础 资料名备注状态阅读时间《深入理解计算机系统》很多大厂面…

实验室预约系统|基于Springboot+Vue实现学校实验室预约管理系统

作者主页&#xff1a;编程指南针 作者简介&#xff1a;Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师 主要内容&#xff1a;Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助 收藏点赞不迷路 关注作者有好处 文末获取源…

JAVA中那些令人眼花缭乱的锁

一、开局一张图带你了解java相关的锁 二、乐观锁和悲观锁 1、悲观锁 悲观锁对应于生活中悲观的人&#xff0c;悲观的人总是想着事情往坏的方向发展。 举个生活中的例子&#xff0c;假设厕所只有一个坑位了&#xff0c;悲观锁上厕所会第一时间把门反锁上&#xff0c;这样其他…

python pyqtgraph绘图库

pyqtgraph官网 PyQtGraph被大量应用于Qt GUI平台&#xff08;通过PyQt或PySide&#xff09;&#xff0c;因为它的高性能图形和numpy可用于大量数据处理。 特别注意的是&#xff0c;pyqtgraph使用了Qt的GraphicsView框架&#xff0c;它本身是一个功能强大的图形系统; 我们将最优…

知识付费海哥:这样做课,不赚钱都难

现在不少人开始了开发网课&#xff0c;卖网课赚钱&#xff0c; 但是在网课开发时&#xff0c;很多人开始的时候&#xff0c;关注的点就错了&#xff01; 自己喜欢钓鱼&#xff0c;就开发钓鱼的课&#xff0c; 自己喜欢演讲&#xff0c;就开发演讲的课&#xff0c; 自己喜欢…

Dubbo入门(二)——IDEA下Dubbo+Zookeeper搭建

目录一、Zookeeper1.1 下载1.2 安装1.3 修改配置文件1.4 启动二、Dubbo插件搭建三、手动创建3.1 创建项目3.1.1 pom依赖3.2 api模块3.2.1 pom依赖3.2.2 实体类3.2.3 service接口3.3 provider3.3.1 pom依赖3.3.2 配置文件3.3.3 mapper3.3.4 service实现类3.3.5 启动类3.4 consum…

冶金工艺流程(钢铁全流程)

工艺图 工艺讲解 生产流程从矿石原料采集开始,对于低品位的矿石&#xff0c;必须在冶炼前经选矿工序先选出铁精矿&#xff0c;然后进一步制成烧结矿或球团矿。 ————————————————————————————— 高炉冶炼是一个连续的、大规模的高温生产过程。铁矿石…

为什么Aruba始终走在网络世界的前列?

编辑 | 阿冒 设计 | 沐由关于网络的价值&#xff0c;梅特卡夫定律&#xff08;Metcalfes law&#xff09;曾经在多年前就明白无误地告诉我们&#xff1a;VKN。其中&#xff0c;V代表一个网络的价值&#xff0c;N代表这个网络的节点数&#xff0c;K代表价值系数。如果梅特卡夫…

47. 批量规范化 代码从零开始实现 + 简洁实现

1. 从零实现 下面&#xff0c;我们从头开始实现一个具有张量的批量规范化层。 import torch from torch import nn from d2l import torch as d2l# X是输入&#xff0c;gamma, beta是两个可以学习的参数&#xff0c;moving_mean, moving_var是整个数据集的均值和方差&#xf…

ssh登录——scp传文件

一、ssh登录 1.基本用法 远程登录服务器&#xff1a; ssh userhostname# user: 用户名 # hostname: IP地址或域名 第一次登录时会提示&#xff1a; The authenticity of host 123.57.47.211 (123.57.47.211) cant be established. ECDSA key fingerprint is SHA256:iy237y…

十分钟掌握 “UML ” 的基本使用

十分钟掌握 “UML ” 的基本使用 每博一文案 很喜欢这样一段话&#xff1a;内可以不跟别人计较&#xff0c;但一定要学会维护自己&#xff0c;你可以不跟别人争抢&#xff0c;但应该懂得远离小人。 人生在世&#xff0c;我们会遇到形形色色的人&#xff0c;人心隔肚皮&#xf…

Pytorch深度学习实战——第3章课后习题

1.从list(range(9))list(range(9))list(range(9))中创建一个张量aaa并预测检查其大小、偏移量、步长。 import torch atorch.tensor(list(range(9))) print(a.storage_offset())#偏移量 print(a.stride())#步长 print(a.size())#大小a)使用ba.view(3,3)ba.view(3,3)ba.view(3,…

Aspose.PDF for Java系列3-创建复杂的PDF

创建复杂PDF 上篇文章展示了使用Java和Aspose.PDF简单步骤。本文中&#xff0c;我们将使用Java和Aspose.PDF创建更复杂的文档结构。此示例中&#xff0c;我们将创建包含图片、两个文本片段&#xff08;标题和段落&#xff09;和表格。 创建文档参考以下步骤&#xff1a; 实例…

被房地产坑惨的老板电器,终于要“回血”了!

近期&#xff0c;随着房地产行业重新被定义为“国民经济的支柱产业”&#xff0c;叠加疫情防控转向&#xff0c;笼罩在家电行业上空的阴霾逐渐消散&#xff0c;家电股预期改善&#xff0c;纷纷迎来估值修复。尤其是曾遭房地产暴击的老板电器&#xff0c;有望抓住房地产回暖的窗…