猿问

如何修复 jFairy 中的 java.lang.NoClassDefFoundError:

我已经使用 mvnw install 命令从 git 存储库([1]:https : //github.com/Devskiller/jfairy.git)构建了 jFairy 项目。然后我已将编译的 jar 文件导入到我的项目中。


package userdao;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.sql.ResultSet;

import com.devskiller.jfairy.Fairy;

import com.devskiller.jfairy.producer.person.Person;

import userdao.User;

/**

 *

 * @author loveu

 */

public class UserDao {


    /**

     * @param args the command line arguments

     * @throws java.lang.ClassNotFoundException

     * @throws java.sql.SQLException

     */

    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        UserDao dao = new UserDao();

        User user = new User();

        Fairy fairy = Fairy.create();

        Person person = fairy.person();

        user.setId(person.getFullName());

        user.setName(person.getFirstName());

        user.setPassword(person.getEmail());

        dao.add(user);

        System.out.println(user.getId() + "successfuly");

        User  user2 = dao.get(user.getId());

        System.out.println(user2.getName());

        System.out.println(user2.getPassword());       


        // TODO code application logic here

    }    



红糖糍粑
浏览 202回答 2
2回答

达令说

您可以在 中找到有关所需库的信息pom.xml,使用 Apache Maven 等工具构建 Java 应用程序要容易得多。&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.yaml</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>snakeyaml</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.20</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.commons</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>commons-lang3</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>3.7</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.commons</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>commons-text</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.2</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.commons</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>commons-math3</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>3.6.1</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.google.guava</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>guava</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>24.0-jre</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.slf4j</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>slf4j-api</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.7.25</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.google.inject</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>guice</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>4.2.0</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.google.inject.extensions</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>guice-assistedinject</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>4.2.0</version>&nbsp; &nbsp; </dependency>

互换的青春

您需要将包含此类的类或 .jar 文件添加到 java 类路径中。
随时随地看视频慕课网APP

相关分类

Java
我要回答