Solved Hello everyone, I'm trying to use Hibernate for my paper server. I'm getting the error.

localhostov

New member
Dec 7, 2023
3
0
1
can you tell me exactly how to use it?
I use these flags to start a build: build shadowJar --offline -x test --continuous.

and I still get the same error as before.

here is my new configuration:

You need to use the Gradle shadow plugin to include hibernate in your plugin jar.

Code:
plugins {
    id 'java'
    id("com.github.johnrengelman.shadow") version "8.1.1"

}

group = 'org.andrewkydev'
version = '1.0'

repositories {
    mavenCentral()
    maven {
        name = "papermc-repo"
        url = "https://repo.papermc.io/repository/maven-public/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
}



dependencies {
    implementation 'org.projectlombok:lombok:1.18.28'
    implementation 'org.projectlombok:lombok:1.18.28'
    compileOnly "io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT"
    annotationProcessor 'org.projectlombok:lombok:1.18.24' // Lombok процессор
    shadow "org.hibernate.orm:hibernate-core:6.4.0.Final"
    implementation "org.hibernate.orm:hibernate-core:6.4.0.Final"


}

def targetJavaVersion = 17
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release.set(targetJavaVersion)
    }
}

shadowJar {
    archiveBaseName.set('shadow')
    archiveClassifier.set('')
    archiveVersion.set('')
}

task copyToPath(){
    finalizedBy(shadowJar)
    doLast {
        copy {
            from "build/libs/API-1.0.jar"
            into ".."
        }
    }
}


processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}




tasks.build.finalizedBy('copyToPath')
 

ItsRainingHP

New member
Jan 8, 2024
1
1
3
Hello! I use hibernate for my plugins as well. Very useful tool. I use maven but this should work. Do note, you need drivers to connect to the database. The drivers help make queries based on database type.

Code:
dependencies {
implementation "org.hibernate.orm:hibernate-core:6.2.3.Final"                    //Hibernate
implementation "com.h2database:h2:2.1.214"                                       //H2 driver
implementation "com.mysql:mysql-connector-j:8.0.33"                              //MySQL Driver
implementation "org.postgresql:postgresql:42.6.0"                                //PostGres Driver
}

shadowJar {
    archiveFileName = "MyPlugin-${version}.jar"
}

I use Libby to externally download libraries based on Server type (Spigot/Paper) to help keep my Jar size low. Additionally, I recommend looking at Cloud Command Framework, InvUI by xenondevs, Aikar's TaskChain, and carleslc Simple-YAML libraries for examples and/or usage in your plugin development.

https://github.com/AlessioDP/libby
https://github.com/NichtStudioCode/InvUI
https://github.com/aikar/TaskChain
https://github.com/Carleslc/Simple-YAML
 
  • Like
Reactions: localhostov

localhostov

New member
Dec 7, 2023
3
0
1
Hello! I use hibernate for my plugins as well. Very useful tool. I use maven but this should work. Do note, you need drivers to connect to the database. The drivers help make queries based on database type.

Code:
dependencies {
implementation "org.hibernate.orm:hibernate-core:6.2.3.Final"                    //Hibernate
implementation "com.h2database:h2:2.1.214"                                       //H2 driver
implementation "com.mysql:mysql-connector-j:8.0.33"                              //MySQL Driver
implementation "org.postgresql:postgresql:42.6.0"                                //PostGres Driver
}

shadowJar {
    archiveFileName = "MyPlugin-${version}.jar"
}

I use Libby to externally download libraries based on Server type (Spigot/Paper) to help keep my Jar size low. Additionally, I recommend looking at Cloud Command Framework, InvUI by xenondevs, Aikar's TaskChain, and carleslc Simple-YAML libraries for examples and/or usage in your plugin development.

https://github.com/AlessioDP/libby
https://github.com/NichtStudioCode/InvUI
https://github.com/aikar/TaskChain
https://github.com/Carleslc/Simple-YAML
I made a mistake, it turns out everything was already working, and the shadowJar task was already working out, I just didn't look at the build folder