Jasypt加密异常:线程“ main”中的异常java.lang.NoClassDefFoundError:org / jasypt / encryption / StringEncryptor

问题描述 投票:0回答:1

我有一个简单的Java控制台应用程序,在其中我使用Jasypt1.9.2进行数据库连接字符串的加密。该代码在Eclipse中运行正常,但是导出为Jar的应用程序出现此错误enter image description here

这是我简单的Main类:

    public static void main (String args[])
 {
try {


            GetConnection config = new GetConnection();
            out = config.getLogFile();
            System.out.println("Start");
            Interface.writeLine(out, "Start");

            while (true) {
            new Interface().ProcessProcedure();
            new Interface().ProcessKTP();
            new Interface().TransferToPRF();
            System.out.println("End");



        Thread.sleep(90000);
            }



        }
        catch (java.lang.Exception ex) {
            System.out.println("Error:"+ex);
        }
    }

这是我的GetConnection类

public Connection getSql(BufferedWriter out){

        try{


                StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();       

                prop = new EncryptableProperties(encryptor);    //--fOR ENCRYPTED PASSWORD


                String fileName = System.getProperty("user.dir") + "\\configuration.properties";
                InputStream is = new FileInputStream(fileName);    



            //InputStream inputStream;



                if (is != null) {
                    prop.load(is);
                } else {
                    throw new FileNotFoundException("Configuration property not found");
                }


            String Driver =  prop.getProperty("sqlserver.driver");
            String url = prop.getProperty("sqlserver.durl");
            String id = prop.getProperty("sqlserver.uid");
            key = "123"                                                      
            encryptor.setPassword(key);                                     
            String sqlpass = prop.getProperty("sqlserver.pass").trim();


            Class.forName(Driver).newInstance();
            Connection conMSSQL = DriverManager.getConnection (url,id,sqlpass);




            if(conMSSQL != null && conMSSQL.isValid(0)) {

                GetConnection.writeLine(out,"Connection established");


            }
            return conMSSQL;
            }
            catch( Exception ex ){

                GetConnection.writeLine(out,"Exception at Kondor connection");  
                GetConnection.writeLine(out,ex.getMessage());


                return null;
            }


    }

我已经检查并验证了Jasypt1.9.2.jar条目的类路径。请帮忙。

java noclassdeffounderror jasypt
1个回答
0
投票

您已经将项目导出到JAR文件,而没有导出依赖关系。

从日食导出时选择package选项。

© www.soinside.com 2019 - 2024. All rights reserved.