springboot第21集:SSO

news2024/9/20 10:46:15
  • 单点登录

  • 单点登出

  • 支持跨域单点登录

  • 支持跨域单点登出

1fb43874fe157f870b6096e4868ebe89.png前台站点:业务站点A,业务站点B

SSO站点:登录,退出

SSO服务:登录,登录状态,登出

数据库,登录状态缓存在Redis

  • 登录时序图

客户端,访问需要登录的页面,从业务站点,如果未从Cookie中获取AuthToken,跳转到登录页面,访问SSO站点,提交用户名,密码,验证用户登录的 SSO 服务,访问DB验证账号,保存登录状态 Redis,返回成功Redis,返回AuthToken,将AuthToken放入Cookie中 domian = test.com 返回 302:跳转到页面,将AuthToken保存到Cookie中,domain = test.com,跳转到访问的页面

  • 登录完成之后通过回调的方式,将AuthToken传递给主域名之外的站点,该站点自行将AuthToken保存在当前域下的Cookie中。

  • 登出完成之后通过回调的方式,调用非主域名站点的登出页面,完成设置Cookie中的AuthToken过期的操作。

这个错误提示表明,代码尝试从ServletContext中调用一个名为getVirtualServerName()的方法,但是该方法不存在。这可能是由于以下原因之一导致的:

  1. Servlet API版本不兼容 - getVirtualServerName()方法是在Servlet API 3.1中引入的。如果代码是在旧版本的Servlet API下编译的,那么它将无法识别getVirtualServerName()方法。

  2. 应用程序服务器问题 - 如果正在运行应用程序服务器,并且该服务器未按照规范实现ServletContext接口,则可能会遇到此问题。在这种情况下,更新应用程序服务器可能解决问题。

修复问题

  1. 检查代码是否使用了正确版本的Servlet API。如果没有,请升级的Servlet API并重新编译代码。

  2. 确保正在运行符合规范的应用程序服务器。如果已经在使用符合规范的应用程序服务器,请尝试更新它以获取最新的Servlet API实现。

package com.wxapp.app;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
@MapperScan("com.wxapp.app.dao")
@MapperScan("com.wxapp.app.mapper")
public class AdminApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(AdminApplication.class);
        application.setBannerMode(Banner.Mode.OFF);
        application.run(args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(AdminApplication.class);
    }

}
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
    <groupId>com.github.qcloudsms</groupId>
    <artifactId>qcloudsms</artifactId>
    <version>1.0.6</version>
</dependency>
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.83</version>
</dependency>
<dependency>
    <groupId>com.github.penggle</groupId>
    <artifactId>kaptcha</artifactId>
    <version>2.3.2</version>
</dependency>

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
</dependency>

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.7</version>
</dependency>

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <!--            <version>3.4.3</version>-->
    <version>3.1.0</version>
</dependency>
<!-- redis依赖commons-pool 这个依赖一定要添加 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
</dependency>

<!--调用 HTTP 请求-->
<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>3.8.1</version>
</dependency>
<dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.6.5</version>
</dependency>

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.2.6</version>
</dependency>
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.72</version>
</dependency>
<dependency>
    <groupId>com.auth0</groupId>
    <artifactId>java-jwt</artifactId>
    <version>3.2.0</version>
</dependency>
@RestController
@RequestMapping("/article")
@Slf4j
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    /**
     * 查询文章列表
     */
    @NoAuth
    @RequiresPermissions("article:list")
    @GetMapping("/listArticle")
    public JSONObject listArticle(HttpServletRequest request) {
        return articleService.listArticle(CommonUtil.request2Json(request));
    }
    /**
     * 新增文章
     */
    @NoAuth
    @RequiresPermissions("article:add")
    @PostMapping("/addArticle")
    public JSONObject addArticle(@RequestBody JSONObject requestJson) {
        CommonUtil.hasAllRequired(requestJson, "content");
        return articleService.addArticle(requestJson);
    }
    /**
     * 修改文章
     */
    @RequiresPermissions("article:update")
    @PostMapping("/updateArticle")
    public JSONObject updateArticle(@RequestBody JSONObject requestJson) {
        CommonUtil.hasAllRequired(requestJson, "id,content");
        return articleService.updateArticle(requestJson);
    }
}
public interface ArticleDao {
    /**
     * 新增文章
     */
    int addArticle(JSONObject jsonObject);
    /**
     * 统计文章总数
     */
    int countArticle(JSONObject jsonObject);
    /**
     * 文章列表
     */
    List<JSONObject> listArticle(JSONObject jsonObject);
    /**
     * 更新文章
     */
    int updateArticle(JSONObject jsonObject);
}
@Service
public class ArticleService {
    @Autowired
    private ArticleDao articleDao;
    /**
     * 新增文章
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject addArticle(JSONObject jsonObject) {
        articleDao.addArticle(jsonObject);
        return CommonUtil.successJson();
    }
    /**
     * 文章列表
     */
    public JSONObject listArticle(JSONObject jsonObject) {
        CommonUtil.fillPageParam(jsonObject);
        int count = articleDao.countArticle(jsonObject);
        List<JSONObject> list = articleDao.listArticle(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
    }
    /**
     * 更新文章
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject updateArticle(JSONObject jsonObject) {
        articleDao.updateArticle(jsonObject);
        return CommonUtil.successJson();
    }
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.wxapp.app.dao.ArticleDao">
    <insert id="addArticle" parameterType="com.alibaba.fastjson.JSONObject">
        INSERT INTO article (content) VALUES (#{content})
    </insert>
    <select id="countArticle" resultType="Integer">
        SELECT COUNT(*) FROM article
    </select>
    <select id="listArticle" resultType="com.alibaba.fastjson.JSONObject">
        SELECT w.id,
               w.content,
               date_format(w.create_time, '%Y.%m.%d %T') createTime,
               date_format(w.update_time, '%Y.%m.%d %T') updateTime
        FROM article w
        ORDER BY w.id DESC
            LIMIT #{offSet}, #{pageRow}
    </select>
    <update id="updateArticle" parameterType="com.alibaba.fastjson.JSONObject">
        UPDATE article
        SET content = #{content}
        WHERE id = #{id}
    </update>
</mapper>
@Service
@Slf4j
public class LoginService {
    @Autowired
    private LoginDao loginDao;
    /**
     * 登录提交
     */
    public JSONObject authLogin(JSONObject jsonObject) {
        String phone = jsonObject.getString("phone");
        String code = jsonObject.getString("code");
        JSONObject info = new JSONObject();
        JSONObject user = loginDao.checkUser(phone, code);
        if (user == null) {
            throw null;
        }
        String successMsg = "登录成功";
        info.put("msg", successMsg);
        return CommonUtil.successJson(info);
    }

    /**
     * 查询当前登录用户的权限等信息
     */
    public JSONObject getInfo(JSONObject jsonObject) {
        //从session获取用户信息
        String phone = jsonObject.getString("phone");
        //SessionUserInfo userInfo = tokenService.getUserInfo();
        SessionUserInfo userInfo = loginDao.getUserInfo(phone);
        log.info(userInfo.toString());
        return CommonUtil.successJson(userInfo);
    }

    /**
     * 推出登录
     */
    public JSONObject logout() {
        JSONObject info = new JSONObject();
        String successMsg = "登出成功";
        info.put("msg", successMsg);
        return CommonUtil.successJson(info);
    }
}
public interface LoginDao {
    JSONObject checkUser(@Param("phone") String phone, @Param("code") String code);
    //Login login(@Param("phone") String phone, @Param("code") String code);

    SessionUserInfo getUserInfo(String phone);

    Set<String> getAllMenu();

    Set<String> getAllPermissionCode();
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.wxapp.app.dao.LoginDao">
    <select id="checkUser" resultType="com.alibaba.fastjson.JSONObject">
        SELECT * FROM la_user WHERE phone=#{phone} AND code=#{code}
    </select>

    <resultMap id="userInfo" type="com.wxapp.app.dto.session.SessionUserInfo">
        <id column="id" property="id"/>
        <result column="phone" property="phone"/>
        <result column="username" property="username"/>
        <result column="nickname" property="nickname"/>
        <collection property="roleIds" ofType="Integer">
            <id column="roleId"/>
        </collection>
        <collection property="menuList" ofType="String">
            <id column="menuCode"/>
        </collection>
        <collection property="permissionList" ofType="String">
            <id column="permissionCode"/>
        </collection>
    </resultMap>

    <select id="getUserInfo" resultMap="userInfo">
        SELECT u.id              id,
               u.phone,
               u.username,
               u.nickname,
               ur.role_id        roleId,
               p.menu_code       menuCode,
               p.permission_code permissionCode
        FROM la_user u
              LEFT JOIN sys_user_role ur on u.id = ur.user_id
              LEFT JOIN sys_role r ON r.id = ur.role_id
              LEFT JOIN sys_role_permission rp ON r.id = rp.role_id
              LEFT JOIN sys_permission p ON rp.permission_id = p.id
        WHERE u.phone=#{phone}
    </select>
    <select id="getAllMenu" resultType="String">
        select distinct(menu_code)
        from sys_permission;
    </select>
    <select id="getAllPermissionCode" resultType="String">
        select distinct(permission_code)
        from sys_permission;
    </select>
</mapper>
@RestController
@RequestMapping(value = "/login1")
@Slf4j
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录
     */
    @NoAuth
    @RequestMapping(value = "/auth", method = RequestMethod.POST)
    //@PostMapping("/auth")
    public JSONObject authLogin(@RequestBody JSONObject requestJSON) {
        CommonUtil.hasAllRequired(requestJSON, "phone,code");
        return loginService.authLogin(requestJSON);
    }

    /**
     * 查询当前登录用户的信息
     */
    @NoAuth
    @PostMapping("/getInfo")
    public JSONObject getInfo(@RequestBody JSONObject requestJSON) {
        return loginService.getInfo(requestJSON);
    }

    /**
     * 登出
     */
    @PostMapping("/logout")
    public JSONObject logout() {
        return loginService.logout();
    }
}
package com.wxapp.app.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wxapp.app.pojo.User;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface UserMapper extends BaseMapper<User> {
}
package com.wxapp.app.dto.session;

import lombok.Data;

import java.util.List;
import java.util.Set;

/**
 * 保存在session中的用户信息
 */
@Data
public class SessionUserInfo {
    private int id;
    private String phone;
    private String username;
    private String nickname;
    private List<Integer> roleIds;
    private Set<String> menuList;
    private Set<String> permissionList;
}
package com.wxapp.app.config.annotation;

public enum Logical {
    AND, OR, NOT;
}
package com.wxapp.app.config.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 访问此接口需要的权限
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequiresPermissions {
    String[] value();
    Logical logical() default Logical.AND;
}
package com.wxapp.app.common;

import lombok.Data;

@Data
public class Result<T> {

    //操作代码
    Integer code;

    //提示信息
    String message;

    //结果数据
    T data;

    public Result() {
    }

    public Result(ResultCode resultCode) {
        this.code = resultCode.code();
        this.message = resultCode.message();
    }

    public Result(ResultCode resultCode, T data) {
        this.code = resultCode.code();
        this.message = resultCode.message();
        this.data = data;
    }

    public Result(String message) {
        this.message = message;
    }

    public static Result SUCCESS() {
        return new Result(ResultCode.SUCCESS);
    }

    public static <T> Result SUCCESS(T data) {
        return new Result(ResultCode.SUCCESS, data);
    }

    public static Result FAIL() {
        return new Result(ResultCode.FAIL);
    }

    public static Result FAIL(String message) {
        return new Result(message);
    }

}

主要是Error creating bean with name 'sqlSessionFactory',这个是在XXX.xml(spring和mybatis整合的xml文件)中定义

并且出现的,其主要意思是xml文件没有配置好。原因大概有以下:

1.spring和mybatis结合的时候在spring配置bean的配置文件中没有把配置sqlSessionFactory中的dataSource和配置数据库连 连接池的dataSource放在同一个配置文件中;

2.mybatis的xml配置文件没有把mybatis的映射文件和Dao接口相互关联配置在一起;

3.虽然定义了数据库连接池的信息,但是可能没有连接到数据库;

我的解决方案:首先确认了数据库在数据库连接池中的配置并确定了数据库的连接状态完好,其次将有关dataSource有关的mybatis配置以及数据库连接池的配置都放在了同一个spring的xml配置文件中,最后再次需要确定spring、mybatis以及数据库连接池之间的相互关联关系是正常的,需要检查mybatis的xml配置文件和xml映射配置文件中相互映射(xml配置文件中的mapper以及xml映射文件中的namespace)是否正确。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory

解决方法:

在SpringBootApplication启动类上添加如下注解:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
datasource:
  druid:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/ssm_db?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai
    username: root
    password:
ef0146f981c541266da767c195486f9e.png
image.png

service类上面没有@service注解或者mapper上没有@Repository注解,但是这种情况比较少见,一般不会忘记。

4c34ee707152d7d669990985d0199719.png
image.png
d2aa5d614db8adaa8b6edcfa638bdd23.png
image.png
package com.wxapp.app;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class AdminApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(AdminApplication.class);
        application.setBannerMode(Banner.Mode.OFF);
        application.run(args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(AdminApplication.class);
    }

}
  1. 确认 SysLoginService 类被正确地声明和定义,且放置在了 Spring 扫描的包路径下。

  2. 如果 SysLoginService 是通过注解方式来声明的,那么要确保该类上已经添加了正确的注解,例如 @Service@Component

  3. 如果 SysLoginService 类依赖于其它 Bean,请确保这些 Bean 已经正确地被声明和定义,并且也位于 Spring 扫描的包路径下。

  4. 确认在 Spring 配置文件中添加了正确的组件扫描配置,以便 Spring 能够扫描到 SysLoginService 类和其它相关的 Bean。

如果以上步骤都已确认无误,但问题仍然存在,可以考虑使用 Spring 的调试工具来进行进一步的排查。

package com.wxapp.app;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class WxAppApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(WxAppApplication.class);
        application.setBannerMode(Banner.Mode.OFF);
        application.run(args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(WxAppApplication.class);
    }

}

基于mybatis开发,新功能基于mybatis-plus开发,同时依赖如下两个jar包

mybatis-spring-boot-starter

mybatis-plus-boot-starter

移除mybatis-spring-boot-starter依赖

原配置如下:

mybatis:
    mapperLocations: classpath:mapper/**/*.xml

新配置:

mybatis-plus:
  mapperLocations: classpath:mapper/**/*.xml,classpath:/mybatis-plus/*.xml

主要就是在解决从mybatis切换到mybatis-puls后,使用了BaseMapper的用户mapper接口与XXXmapper.xml文件方法绑定的问题,为使用了BaseMapper的用户mapper接口在内存中生成xml映射文件

关于Springboot+Mybatis——Error creating bean with name 'sqlSessionFactoryBean--Mapper映射问题

1.mybatis中

<!-- Spring-Mybatis -->
<dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.2</version>
        <!--原Mybatis中需排除下面2个依赖-->
        <exclusions>
                <exclusion>
                        <groupId>org.mybatis</groupId>
                        <artifactId>mybatis</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>org.mybatis</groupId>
                        <artifactId>mybatis-spring</artifactId>
                </exclusion>
        </exclusions>
</dependency>
  1. pagehelper 中

<!-- 分页插件 -->
<dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <version>1.2.3</version>
        <!--需排除下面包-->
        <exclusions>
                <exclusion>
                        <groupId>org.mybatis.spring.boot</groupId>
                        <artifactId>mybatis-spring-boot-starter</artifactId>
                </exclusion>
        </exclusions>
</dependency>

3.引入[Mybatis-plus]

<!--引入Mybatis-plus-->
<dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.3.2</version>
</dependency>

4.引入autoconfigure

<!--引入autoconfigure-->
<dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
        <version>2.1.4</version>
</dependency>
  1. 修改配置文件,将原 mybatis 改成 mybatis-plus

mybatis-plus:
  mapper-locations: classpath*:/mapper/*.xml,classpath*:/lemon/mapper/*.xml
  configuration:
    mapUnderscoreToCamelCase: true
mybatis-plus:
  mapper-locations: classpath*:/mapper/*.xml,classpath*:/mapper/**/*.xml
  configuration:
    mapUnderscoreToCamelCase: true
4222896dc93776d15002447fc66cf318.png
SpringBoot启动流程.png

加群联系作者vx:xiaoda0423

仓库地址:https://github.com/webVueBlog/JavaGuideInterview

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

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

相关文章

【Swift】String与Sbustring区别与联系

String 还是字符串&#xff0c;始终如一。Substring 是string的切片。它们与base string共享内存buffer&#xff0c;并拥有一对范围索引。StringProtocol 抽取出字符串的特征以及如何访问其功能&#xff0c;放进一个协议中。String及Substring都遵循StringProtocol。 字符串在不…

从零开始学习机器学习和深度学习:基础知识、编程工具和实践经验

当涉及到机器学习和深度学习时&#xff0c;许多人可能感到不知所措。本文将为您提供入门机器学习和深度学习的基础知识。 什么是机器学习&#xff1f; 机器学习是人工智能的一个分支&#xff0c;其主要目的是通过训练算法来实现任务&#xff0c;而不是手动编程来实现任务。机器…

MySQL原理(二):逻辑架构和执行流程

前言 上一篇介绍了 MySQL 默认的 InnoDB 存储引擎是如何存储和组织数据的&#xff0c;这一篇将介绍 MySQL 的逻辑架构&#xff0c;以及分析一条 SQL 语句的具体执行过程。 逻辑架构 MySQL 的架构共分为两层&#xff1a;Server 层和存储引擎层。 Server 层负责建立连接、分析…

HiEV独家 | 比亚迪高阶智驾终于来了 ,新款汉首发,多车型将搭载

作者 | 德新 编辑 | 马波 比亚迪上马高阶辅助驾驶&#xff0c;首先从高速NOA开始。 HiEV获悉&#xff0c;今年第三季度&#xff0c;比亚迪将在新的 汉车型 上&#xff0c;搭载高速领航辅助驾驶功能&#xff08;俗称高速NOA&#xff09;。继汉之后&#xff0c;王朝系列唐…

【神经网络】tensorflow实验10 -- 人工神经网络(1)

1. 实验目的 ①理解并掌握误差反向传播算法&#xff1b; ②能够使用单层和多层神经网络&#xff0c;完成多分类任务&#xff1b; ③了解常用的激活函数。 2. 实验内容 ①设计单层和多层神经网络结构&#xff0c;并使用TensorFlow建立模型&#xff0c;完成多分类任务&#xf…

Packet Tracer - 第 2 层安全

Packet Tracer - 第 2 层安全 目标 将 Central 交换机指定为根网桥。 保护生成树参数的安全&#xff0c;以防止 STP 恶意操纵 攻击。 启用端口安全以防御 CAM 表泛洪攻击。 拓扑图 背景/ 场景 最近网络遭到了一些 攻击。出于此原因&#xff0c;网络管…

2022年平均工资揭晓!2022年IT行业平均工资超高!最赚钱的行业是......IT! 看看最赚钱的职位是什么?

2022年平均工资发布&#xff01;最赚钱的行业是…IT 文章目录 2022年平均工资发布&#xff01;最赚钱的行业是......IT2022年城镇非私营单位就业人员年平均工资按区域、行业门类、登记注册类型分组的城镇非私营单位就业人员年平均工资&#xff1a; 附注&#xff1a;2022年城镇私…

为AIGC敲响警钟!千亿级赛道为何成了作恶温床?

‍数据智能产业创新服务媒体 ——聚焦数智 改变商业 随着人工智能通用大模型的问世&#xff0c;全球对AIGC技术的强大潜力有了更加深刻的认识。然而&#xff0c;这也引发了诸多关于AIGC技术可信度、隐私保护以及知识产权等问题的争议&#xff0c;引起了广泛关注。 5月9日&…

Windows安装两个MySQL【5.7 + 8.0】

目录 1、下载MySQL82、解压、放置3、配置3-1 添加环境变量3-2 配置文件 my.ini3-3 配置 MySQL 服务3-4 root 通过IP访问 4、连接 ✨ 已安装 MySQL5&#xff0c;再加装MySQL8 1、下载MySQL8 https://dev.mysql.com/downloads/mysql/ MySQL :: Download MySQL Community Server…

VScode 中运行C++,并用g++命令、CMake、配置launch.josn和tasks.json来运行和调试可执行文件

前期安装准备 安装VScode、cmake、mingw32 &#xff08;具体版本如下&#xff09; VSCodeUserSetup-x64-1.78.0.exe cmake-3.26.3-windows-x86_64.msi x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z 将这几个的bin目录加入系统环境变量&#xff08;右击此电脑&#xff0c…

Java基础之ConcurrentHashMap答非所问

ConcurrentHashMap的数据结构是什么&#xff1f; ConcurrentHashMap仅仅是HashMap的线程安全版本&#xff0c;针对HashMap的线程安全优化&#xff0c;所以HashMap有的特点ConcurrentHashMap同意具有&#xff0c; ConcurrentHashMap的数据结构跟HashMap是一样的。 在JDK7版本使用…

中学理化生实验室建设及配置要求

中学理化生实验室是中学阶段进行物理、化学、生物教学和研究的场所。其可以满足实验教学要求,实验室提供必要的仪器、设备、工具、材料等课程资源&#xff0c;方便学生熟悉并接触一些实验仪器设备&#xff0c;学习掌握基本实验技能。同时&#xff0c;实验室科学合理的方案配置&…

MySQL原理(十):主从架构

前言 上一篇介绍了 MySQL 的表分区和分库分表&#xff0c;这一篇将介绍主从架构相关的内容。 主从架构 常见的主从架构模式有四种&#xff1a; 一主多从架构&#xff1a;适用于读大于写的场景&#xff0c;采用多个从库来分担数据库系统的读压力。多主架构&#xff1a;适用于…

康希诺生物:新冠疫苗影响当期业绩,毛利润减少89.92%

来源;猛兽财经 作者&#xff1a;猛兽财经 猛兽财经获悉&#xff0c;由于4月28日&#xff0c;康希诺生物&#xff08;06185&#xff09;发布2023年一季度报告&#xff0c;收入同比下滑及利润端亏损&#xff0c;主要由于新冠疫苗需求量同比大幅下降&#xff0c;以及产品价格调整…

在 IDEA 中创建 Java Web 项目的方式(详细步骤教程)

开发环境 以下是我的开发环境 JDK 1.8Maven 3.6.3Tomcat 9.0IDEA 2019&#xff08;2019 无所畏惧&#xff0c;即使现在已经 2023 年了哈哈哈&#xff09; 最原始的 Java Web 项目 下面的内容可能会因 IDEA 版本不同&#xff0c;而有些选项不同&#xff0c;但是大同小异。 …

【上进小菜猪】使用Ambari提高Hadoop集群管理和开发效率:提高大数据应用部署和管理效率的利器

&#x1f4ec;&#x1f4ec;我是上进小菜猪&#xff0c;沈工大软件工程专业&#xff0c;爱好敲代码&#xff0c;持续输出干货&#xff0c;欢迎关注。 介绍 Hadoop是一种开源的分布式处理框架&#xff0c;用于在一组低成本硬件的集群上存储和处理大规模数据集。Ambari是一种基…

python 获取cookie的方法

在 Web应用程序中&#xff0c;用户访问网站时&#xff0c;通常会请求访问服务器上保存的一些用户信息&#xff08;例如&#xff1a; Cookie&#xff09;&#xff0c;这些信息包含了用户的一些个人信息&#xff0c;比如&#xff1a;姓名、地址、密码等。对于用户来说&#xff0c…

目标检测YOLO实战应用案例100讲-基于YOLOv3的目标检测研究及改进(论文篇)

知识拓展 多尺度特征学习 目前深度学习用于目标检测已经习以为常。从SSD到Yolo系列,其中: 深层网络的感受野比较大,语义信息表征能力强,但是特征图的分辨率低,几何信息的表征能力弱(空间几何特征细节缺乏); 低层网络的感受野比较小,几何细节信息表征能力强,虽然分辨…

国漫画江湖之不良人6真的封神!

国漫画江湖之不良人6真的封神&#xff01; 今天不良人第六季大结局&#xff0c;真的超好看&#xff0c;不仅剧情完整&#xff0c;而且还非常甜&#xff0c;看的非常爽&#xff0c;时长直接拉到40分钟&#xff0c;打斗场面刺激&#xff0c;简直是语言形容不出来的爽&#xff01…

[PyTorch]Onnx模型格式的转换与应用

相较于PyTorch默认的模型存储格式pth而言&#xff0c;onnx具有多端通用&#xff0c;方便部署的优点&#xff08;据称能加快推理速度&#xff0c;但是未验证&#xff09;&#xff0c;本文将介绍如何使用onnx并将原有的pth权重转换为onnx。 一、配置环境 在控制台中使用如下指令 …