在线测评系统(未完结)


  前言:大二刚开始接手了本学院的oj,并管理了一段时间,后来老师给我说我可以开发一个 oj 用来当做毕设。
  我:嗯…(知道开发一个比较困难)
  来来回回最终下定决心开始了 oj 的开发,由于我都是略懂一点(这个最难受了),所以做起来比较困难,也没有什么人可以请教,只能自己一点一点的找网上的。
  在我管理的 oj 中,使用 php 开发的,但是但是,我学的主要的是 java 因此想写一个 java 版本的。在之前,学长接手的时候对于本学院 oj 项目的记录可以说是为零,虽然在我接手的时候不敢说是一片空白,但是也差不多 (>_<) ,经历了一个学期,基本摸清了项目的主要结构,并对项目的一些 bug 进行修改,比如:限制同一账号同时登录多个;补充了对于用户的删除(彻底的),后面的修改 id(这个是 primary key)还没有写,准备带着下一届的学弟开发(因为我也要转手了)。
不足的:还没有了解他的判题机制(当时也是 十分茫然、无助。。。。)
还可以的:对项目主要结构写了自认为可以的解析文档,对以后的开发确定的大致的方向,并留下一些开发经验


继续说本项目:

  在此之前听了 dl 学长的建议使用 docker进行环境的部署,经过好长时间的尝试,还是在 win11 中进行了安装,因为用了好长时间,工具比较全,也不想在去弄别的了。注:Win11 家庭版可以安装 docker !!! 简单使用还是可以的(对我目前的需求来讲)


使用主要工具:
idea 2023
docker 25.0.6(win版)
vsCode

使用主要框架
springBoot 2.6.11


注意!!!

在进行Maven引用或注解引用的时候,一定考虑版本适配问题(刚开始没注意springboot版本适配问题,一直报错)



1、多模块开发(后端)

如何使用多模块开发,可以自己参考其他的

(1).Maven依赖

    <dependencies>
        <!-- 邮箱验证码依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <!--        lvrdqmmdvfgcbdcc-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.32</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.oshi</groupId>
            <artifactId>oshi-core</artifactId>
            <version>6.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>2.0.35</version>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.3.2</version>
        </dependency>
        <!--druid-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.16</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.26</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.6</version>
        </dependency>

        <!--        docker-java-->
        <!--        <dependency>-->
        <!--            <groupId>com.github.docker-java</groupId>-->
        <!--            <artifactId>docker-java</artifactId>-->
        <!--            <version>3.2.13</version>-->
        <!--        </dependency>-->
        <!--        <dependency>-->
        <!--            <groupId>com.github.docker-java</groupId>-->
        <!--            <artifactId>docker-java-core</artifactId>-->
        <!--            <version>3.2.13</version>-->
        <!--        </dependency>-->
        <!--        <dependency>-->
        <!--            <groupId>com.github.docker-java</groupId>-->
        <!--            <artifactId>docker-java-transport-httpclient5</artifactId>-->
        <!--            <version>3.2.13</version>-->
        <!--        </dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.25.Final</version>
        </dependency>
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>3.10.3</version>
        </dependency>


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>2.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20220924</version>
        </dependency>
        <!-- 集成redis依赖  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>redis.clients</groupId>
                    <artifactId>jedis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.lettuce</groupId>
                    <artifactId>lettuce-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!--        weka-->
        <dependency>
            <groupId>nz.ac.waikato.cms.weka</groupId>
            <artifactId>weka-stable</artifactId>
            <version>3.8.6</version>
        </dependency>
        <!--        minio-->
        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>8.2.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

    </dependencies>

(2)swagger配置

刚开始可以只写一个空的Swagger2Config 类,注意在启动类上加上@EnableSwagger2 @EnableWebMvc注解

对于 swagger 的使用可以自行学习
接口文档地址:http://localhost:8080/swagger-ui/index.html#/ (注意本项目的根路径为 /)

@Configuration
@EnableSwagger2
@EnableWebMvc
public class Swagger2Config {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true).groupName("判题测试接口").tags(new Tag("judge相关接口", "ee"))
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.ant("/judge/**"))
                .build();
    }
    @Bean
    public Docket api01(){
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true) .groupName("user管理接口")
                .tags(new Tag("用户管理相关接口","Test01Controller"))
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.ant("/user/**"))
                .build()
               ;
    }

//    //构建 api文档的详细信息函数
//    private ApiInfo apiInfo() {
//        return new ApiInfoBuilder()
//                //页面标题
//                .title("XX平台API接口文档")
//                //创建人
//                .contact(new Contact("冯冬冬", "http://www.javachat.cc",
//                        "3049352171@qq.com"))
//                //版本号
//                .version("1.0")
//                //描述
//                .description("系统API描述")
//                .build();
//    }
}

2、判题机开发

主要是使用docker镜像拉取环境,每次判题的时候新建容器,结束后删除容器

(1)docker

镜像配置:

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  },
  "registry-mirrors": [
    "https://do.nark.eu.org",
    "https://dc.j8.work",
    "https://docker.m.daocloud.io",
    "https://dockerproxy.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://docker.nju.edu.cn"
  ]
}
  • 8
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值