Solved HikariCP question

Discussion in 'Spigot Plugin Development' started by MadMaxCookie, Jun 28, 2016.

  1. What happened if you didn't used maven shade for hikaricp ?
    Code (Java):
    <dependencies>
       <dependency>
         <groupId>com.zaxxer</groupId>
         <artifactId>HikariCP</artifactId>
         <version>LATEST</version>
         <scope>compile</scope>
       </dependency>
    </dependencies>
     
  2. Then you would get Class defound errors, trust me, I've experienced it.
     
  3. And this question has nothing to do with HikariCp lol, its for not shading when you should 0_0
     
  4. hmm so I better use maven shade ?
     
  5. but spigot I already had an project with the HikariCP can someone help me make a maven shade from an existing project ? using IntelliJ
     
  6. Yup.
    Take a look at my pom.xml:

    Code (Text):
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>us.universalpvp</groupId>
        <artifactId>credits</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
        </repositories>
        <dependencies>
            <!--Spigot API-->
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.8.8-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.zaxxer</groupId>
                <artifactId>HikariCP</artifactId>
                <version>LATEST</version>
            </dependency>
        </dependencies>

        <build>
            <finalName>CreditsAPI</finalName>
            <defaultGoal>clean package install</defaultGoal>
            <plugins>
                <plugin>
                    <!-- maven compiler plugin -->
                    <version>3.1</version>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <!-- maven shade plugin -->
                <plugin>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.4.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>
    </project>
     
  7. Just shade Hikari. If you reference an API but it isn't available at runtime, then your program will throw NoClassDefFound errors as avighnash has already stated
     
  8. well yeah once again
     
  9. Well if you know your way around Maven you should know what to add to your pom to shade Hikari from what I showed you
     
  10. @Redrield @avighnash well I'm using maven shade could I use dependancy by uploading file at the same time ? for example importing Vault.
     
  11. Vault is a bad example, as they have a maven repo. But if you mean something that you only have the jarfile for (no maven repo) Just make a dependency with scope system, and add a systemPath tag with the path to the file
     
  12. oh well thanks for that.