Skip to content

安装

本页介绍如何将 LCGYL Framework 添加到你的项目中。

前置要求

  • JDK 21 或更高版本
  • Gradle 8.5+Maven 3.9+
  • 你喜欢的 IDE(推荐 IntelliJ IDEA)

检查 JDK 版本

bash
java -version
# openjdk version "21.0.1" ...

使用 Gradle

方式一:直接依赖

gradle
dependencies {
    implementation 'com.lcgyl:lcgyl-framework-core:2.2.0'
}

方式二:使用 BOM(推荐)

gradle
dependencies {
    // 导入 BOM
    implementation platform('com.lcgyl:lcgyl-framework-dependencies:2.2.0')
    
    // 无需指定版本
    implementation 'com.lcgyl:lcgyl-framework-core'
}

配置仓库

LCGYL Framework 发布在私有 Maven 仓库,需要添加仓库配置:

gradle
repositories {
    mavenCentral()
    
    // LCGYL 私有仓库(必需)
    maven {
        name = "lcgylMaven"
        url = uri("https://nexus.lcgylfamily.cn/repository/maven-public/")
        credentials {
            username = project.findProperty("lcgylMavenUser") ?: "jar-downloader"
            password = project.findProperty("lcgylMavenPassword") ?: "B57opNMl64JSbe"
        }
    }
}

凭证说明

上述凭证为公开只读账号,可直接配置在项目中。也可以将凭证配置在 ~/.gradle/gradle.properties 中:

properties
lcgylMavenUser=jar-downloader
lcgylMavenPassword=B57opNMl64JSbe

使用 Maven

方式一:直接依赖

xml
<dependency>
    <groupId>com.lcgyl</groupId>
    <artifactId>lcgyl-framework-core</artifactId>
    <version>2.2.0</version>
</dependency>

方式二:使用 BOM(推荐)

xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.lcgyl</groupId>
            <artifactId>lcgyl-framework-dependencies</artifactId>
            <version>2.2.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- 无需指定版本 -->
    <dependency>
        <groupId>com.lcgyl</groupId>
        <artifactId>lcgyl-framework-core</artifactId>
    </dependency>
</dependencies>

配置仓库

pom.xml 中添加仓库配置:

xml
<repositories>
    <repository>
        <id>lcgyl-maven</id>
        <name>LCGYL Maven Repository</name>
        <url>https://nexus.lcgylfamily.cn/repository/maven-public/</url>
    </repository>
</repositories>

~/.m2/settings.xml 中配置凭证:

xml
<servers>
    <server>
        <id>lcgyl-maven</id>
        <username>jar-downloader</username>
        <password>B57opNMl64JSbe</password>
    </server>
</servers>

常用模块

模块说明坐标
Core核心框架lcgyl-framework-core
SpringSpring 集成lcgyl-framework-spring
JDBC数据库访问lcgyl-jdbc-plugin
RedisRedis 客户端lcgyl-redis-plugin
WebWeb 增强lcgyl-web-plugin

验证安装

创建一个简单的测试类:

java
import com.lcgyl.framework.core.Application;

public class InstallTest {
    public static void main(String[] args) {
        System.out.println("LCGYL Framework 安装成功!");
        System.out.println("版本: " + Application.getVersion());
    }
}

运行后看到版本号即表示安装成功。

常见问题

Q: 找不到依赖?

确保已正确配置 LCGYL 私有仓库:

  1. 检查仓库地址:https://nexus.lcgylfamily.cn/repository/maven-public/
  2. 检查凭证配置:用户名 jar-downloader
  3. 检查网络连接是否正常

Q: 版本冲突?

使用 BOM 方式管理依赖版本,避免手动指定版本号。

Q: 需要 JDK 21?

是的,LCGYL 使用了 Java 21 的新特性(Virtual Threads、Record 等),不支持更低版本。

下一步

5分钟快速开始

Released under the Apache License 2.0