NutzCN Logo
问答 Fail to born 'org.nutz.dao.impl.NutDao'本地项目数据库解析异常
发布于 2586天前 作者 qq_b8d6444f 1913 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.ioc.IocException: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.NutDao'
by args: [
@({
CreateTime:"2017-10-17 10:30:28",
ActiveCount:0,
PoolingCount:0,
CreateCount:0,
DestroyCount:0,
CloseCount:0,
ConnectCount:0,
Connections:[
]
})] becasue:
Decryption error || Args Error or Abstract Class ?
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:16)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:927)
at org.nutz.lang.Lang.wrapThrow(Lang.java:164)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:105)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:203)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:92)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:64)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.NutDao'
by args: [
@({
CreateTime:"2017-10-17 10:30:28",
ActiveCount:0,
PoolingCount:0,
CreateCount:0,
DestroyCount:0,
CloseCount:0,
ConnectCount:0,
Connections:[
]
})] becasue:
Decryption error || Args Error or Abstract Class ?
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:19)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:76)
... 44 more
Caused by: javax.crypto.BadPaddingException: Decryption error
at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:380)
at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:291)
at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:358)
at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:391)
at javax.crypto.Cipher.doFinal(Cipher.java:2131)
at com.alibaba.druid.filter.config.ConfigTools.decrypt(ConfigTools.java:147)
at com.alibaba.druid.filter.config.ConfigFilter.decrypt(ConfigFilter.java:203)
at com.alibaba.druid.filter.config.ConfigFilter.init(ConfigFilter.java:123)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:511)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)
at org.nutz.trans.Trans.getConnectionAuto(Trans.java:252)
at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:100)
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:154)
at org.nutz.dao.impl.NutDao.(NutDao.java:109)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:16)
... 46 more

18 回复

不知道怎么调

用 "插入代码或日志片段" 按钮重新贴一次

<2017-10-17 10:38:37> <INFO> [org.nutz.dao.jdbc.Jdbcs] - Get Connection from DataSource for JdbcExpert这是刚启动项目 显示数据库连接了
在浏览器敲地址后<2017-10-17 10:42:34> <WARN> [org.nutz.mvc.impl.processor.FailProcessor] - Erro@/index :
org.nutz.ioc.IocException: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.NutDao'
 by args: [
  @({
	CreateTime:"2017-10-17 10:42:34",
	ActiveCount:0,
	PoolingCount:0,
	CreateCount:0,
	DestroyCount:0,
	CloseCount:0,
	ConnectCount:0,
	Connections:[
	]
})] becasue:
Decryption error || Args Error or Abstract Class ?
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:16)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:927)
	at org.nutz.lang.Lang.wrapThrow(Lang.java:164)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:105)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:96)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:185)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:203)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:92)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:64)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:94)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.NutDao'
 by args: [
  @({
	CreateTime:"2017-10-17 10:42:34",
	ActiveCount:0,
	PoolingCount:0,
	CreateCount:0,
	DestroyCount:0,
	CloseCount:0,
	ConnectCount:0,
	Connections:[
	]
})] becasue:
Decryption error || Args Error or Abstract Class ?
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:19)
	at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:76)
	... 44 more
Caused by: javax.crypto.BadPaddingException: Decryption error
	at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:380)
	at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:291)
	at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:358)
	at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:391)
	at javax.crypto.Cipher.doFinal(Cipher.java:2131)
	at com.alibaba.druid.filter.config.ConfigTools.decrypt(ConfigTools.java:147)
	at com.alibaba.druid.filter.config.ConfigFilter.decrypt(ConfigFilter.java:203)
	at com.alibaba.druid.filter.config.ConfigFilter.init(ConfigFilter.java:123)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:511)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)
	at org.nutz.trans.Trans.getConnectionAuto(Trans.java:252)
	at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:100)
	at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:154)
	at org.nutz.dao.impl.NutDao.<init>(NutDao.java:109)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:16)
	... 46 more
出现这些问题 并且浏览器显示的是一堆类似json 串的东西  刚接手的项目 很蒙

没有连上的数据库的

// 这是用了druid的数据库密码加密功能,但密码解密报错了
Caused by: javax.crypto.BadPaddingException: Decryption error
	at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:380)
	at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:291)
	at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:358)
	at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:391)
	at javax.crypto.Cipher.doFinal(Cipher.java:2131)
	at com.alibaba.druid.filter.config.ConfigTools.decrypt(ConfigTools.java:147)
	at com.alibaba.druid.filter.config.ConfigFilter.decrypt(ConfigFilter.java:203)
	at com.alibaba.druid.filter.config.ConfigFilter.init(ConfigFilter.java:123)
这个是浏览器显示的{"detailMessage":"org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.NutDao'\n by args: [\n  @({\n\tCreateTime:\"2017-10-17 10:42:34\",\n\tActiveCount:0,\n\tPoolingCount:0,\n\tCreateCount:0,\n\tDestroyCount:0,\n\tCloseCount:0,\n\tConnectCount:0,\n\tConnections:[\n\t]\n})] becasue:\nDecryption error || Args Error or Abstract Class ?","cause":{"detailMessage":"Fail to born 'org.nutz.dao.impl.NutDao'\n by args: [\n  @({\n\tCreateTime:\"2017-10-17 10:42:34\",\n\tActiveCount:0,\n\tPoolingCount:0,\n\tCreateCount:0,\n\tDestroyCount:0,\n\tCloseCount:0,\n\tConnectCount:0,\n\tConnections:[\n\t]\n})] becasue:\nDecryption error || Args Error or Abstract Class ?","cause":{"detailMessage":"Decryption error","stackTrace":

密码写了明文??

请问怎么解决这个问题啊 我所知道的密码都是明文的,他的加密类 用的是AES的加密方法

。//这个是他的加密类  我是把明文密码直接在这个类里输出了得到的 密文 密码放置在了 dao的配置文件里 ,但是没连上  后来是直接把明文账户 ,密码直接写进dbutil 里的
package com.ruyima.util;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

import org.apache.log4j.Logger;

/**
 * <h3>AES加密算法工具类</h3>
 * 
 */
public class AESUtil {
	static Logger log = Logger.getLogger(AESUtil.class);
	/**
	 * <p>
	 * 加密解密器
	 * </p>
	 * @param password
	 *            密钥
	 * @param cipHerType
	 *            加密器执行模式
	 * @return 加密解密器
	 */
	private static Cipher getAESCipher(String password, int cipHerType) {
		// 算法名称
		String algorithmName = "AES";
		try {
				
			// 密钥生成器
			KeyGenerator kgen = KeyGenerator.getInstance(algorithmName);
			// 使用用户提供的随机源初始化此密钥生成器,使其具有确定的密钥大小
			SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");  
	        secureRandom.setSeed(password.getBytes());  
			
			kgen.init(128, secureRandom);
			// 生成一个密钥
			SecretKey secretKey = kgen.generateKey();
			// 返回基本编码格式的密钥
			byte[] enCodeFormat = secretKey.getEncoded();
			// 根据一个字节数组构造一个 SecretKey
			SecretKeySpec key = new SecretKeySpec(enCodeFormat, algorithmName);
			// 创建密码器
			Cipher cipher = Cipher.getInstance(algorithmName);
			// 初始化为加密模式的常量。
			cipher.init(cipHerType, key);
			return cipher;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (NoSuchPaddingException e) {
			e.printStackTrace();
		} catch (InvalidKeyException e) {
			e.printStackTrace();
		}
		return null;
	}

	
	/**
	 * <p>
	 * 加密
	 * </p>
	 * 
	 * @param content
	 *            需要加密的内容
	 * @param password
	 *            密钥
	 * @return 获取加密后的字节数组
	 */
	private static byte[] encrypt(byte[] byteContent, String password) {
		try {
			// byte[] byteContent = content.getBytes("utf-8");
			// 获取加密模式下的加密器
			Cipher cipher = getAESCipher(password, Cipher.ENCRYPT_MODE);
			// 加密后的字节数组
			byte[] result = cipher.doFinal(byteContent);
			return result;
		} catch (IllegalBlockSizeException e) {
			e.printStackTrace();
		} catch (BadPaddingException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * <p>
	 * 解密
	 * </p>
	 * 
	 * @param content
	 *            待解密内容
	 * @param password
	 *            密钥
	 * @return 解密后的字节数组
	 */
	private static byte[] decrypt(byte[] content, String password) {
		try {
			Cipher cipher = getAESCipher(password, Cipher.DECRYPT_MODE);// 初始化
			byte[] result = cipher.doFinal(content);
			return result;
		} catch (IllegalBlockSizeException e) {
			e.printStackTrace();
		} catch (BadPaddingException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * <p>
	 * 将二进制转换成16进制
	 * </p>
	 * 
	 * @param buf
	 * @return
	 */
	private static String parseByte2HexStr(byte buf[]) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < buf.length; ++i) {
			sb.append(Integer.toHexString((buf[i] & 0xFF) | 0x100).substring(1, 3));
		}
		return sb.toString();
	}

	/**
	 * <p>
	 * 将16进制转换为二进制
	 * </p>
	 * 
	 * @param hexStr
	 * @return
	 */
	private static byte[] parseHexStr2Byte(String hexStr) {
		if (hexStr.length() < 1)
			return null;
		byte[] result = new byte[hexStr.length() / 2];
		for (int i = 0; i < hexStr.length() / 2; i++) {
			int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
			int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
			result[i] = (byte) (high * 16 + low);
		}
		return result;
	}

	/**
	 * 获取加密后的密文
	 * 
	 * @param content
	 *            加密内容
	 * @param password
	 *            秘钥
	 * @return ciphertext 加密后的字串
	 */
	public static String getCiphertext(String content, String password) {
		byte[] byteContent = null;
		try {
			byteContent = content.getBytes("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			log.error("getCiphertext",e);
		}
		byte[] encryptResult = encrypt(byteContent, password);
		String ciphertext = parseByte2HexStr(encryptResult);
		
		return ciphertext;
	}

	/**
	 * <p>
	 * 获取明文
	 * </p>
	 * 
	 * @param ciphertext
	 *            密文
	 * @param password
	 *            密钥
	 * @return 明文
	 */
	public static String getPlaintext(String ciphertext, String password) {
		byte[] decryptBytes = parseHexStr2Byte(ciphertext);
		byte[] decryptResult = decrypt(decryptBytes, password);
		return new String(decryptResult);
	}

	public static void main(String[] args) throws UnsupportedEncodingException {
		
		String content = "11111111";
//		
//		
		String password = "xboxeskeyvalue";
//////		String password = "ruyima";
//////		System.out.println("解密后:" + getPlaintext(content, password));
////
////		// 加密
		String str = getCiphertext(content, password);
		System.out.println("加密前:" + content);
		System.out.println("加密后:" + str);
		System.out.println("解密后:" + getPlaintext(str, password));
		
		//924692bbedd6a62a9442ee4560fe1af1   924692bbedd6a62a9442ee4560fe1af1
		
//		String content="11111111";
//		String password = "RUYIMA";
//		String str = getCiphertext(content, password);
		//System.out.println("==="+"924692bbedd6a62a9442ee4560fe1af1".length());
		//System.out.println("==="+"ae3fc2addb2e3764212caa04527fed76".length());

		//jdbc:mysql://127.0.0.1:3306/ruyima?useUnicode=true&characterEncoding=utf-8
//		System.out.println("加密后,123456=="+getCiphertext("123456", "ruyima"));
//		System.out.println("加密后,zy1356=="+getCiphertext("zy1356", "ruyima"));
		//System.out.println("解密后,123456=="+getPlaintext("0cb9fcf5abb1e26bec745dd54c19a43d", "ruyima"));
//        System.out.println("解密后,password=="+getPlaintext("b25cdeb0db1c9a4c71c53ce5428c776a", "ruyima"));
        //System.out.println("解密后,password=="+getPlaintext("22ef4544890bed27e261c31e4a46146f", "ruyima"));
        //System.out.println("解密后,快递员初始密码:=="+getPlaintext("103346fe8c72213c662c3ce69910108c", "ruyima"));
      //  System.out.println(AESUtil.getCiphertext("12345678", Const.CIPHER_TEXT).trim() + "\t Eop");
        //System.out.println(AESUtil.getCiphertext("920623", Const.CIPHER_TEXT).trim() + "\t exp");
//        System.out.println(AESUtil.getPlaintext("34b0f1459163939bed2739e72cf80349", Const.CIPHER_TEXT).trim() + "\t eop");
//        System.out.println(AESUtil.getPlaintext("c2c88cd5c8592c9465f23f2327aa6ec4", Const.CIPHER_TEXT).trim() + "\t exp FROM DATABASE");
        //System.out.println("加密后=="+getCiphertexnghat("go", "ruyima"));
		//System.out.println("加密后=="+getCiphertext("12455689", "ruyima"));
		System.out.println("解密后=="+getPlaintext("72b85cda44584fef456e0306a75c07dd", "xboxesvalues"));
		//System.out.println("293547de4a779b6c09439c911fb37ef9".equals("293547de4a779b6c09439c911fb37ef9"));
		
        
/*		int i = 0;
		List<Long> list = new LinkedList<Long>();
		do{
			long temp = Math.round(Math.random()*10000000 * 10+10000000);
			if(!list.contains(temp) && temp < 100000000){
				list.add(temp);
				i++;
			}
		}while( i < 2000 );
		int j = 0;
		for(long l : list){
			System.out.println(l);
		}
		System.out.println("----------------------------------////////");
		for(long l : list){
			System.out.println(AESUtil.getCiphertext(String.valueOf(l), Const.CIPHER_TEXT));
		}*/
	}
}

dao.js贴一下, 里面有配的

#这个是dao的配置文件 我感觉是我的密码加密的错误了
#MySQL\u8fde\u63a5\u914d\u7f6e
!-- \u8fde\u63a5\u9a71\u52a8   --
db_driver=com.mysql.jdbc.Driver
!-- \u8fde\u63a5URL --
#db_url=jdbc:mysql://www.i0033.com:3307/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#db_url=jdbc:mysql://115.28.224.50:3300/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
db_url=jdbc:mysql://101.200.182.90:3306/xboxes_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=true
#db_url=jdbc:mysql://ruyimabox.mysql.rds.aliyuncs.com:3309/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
!-- \u7528\u6237 -- 
db_user=dbadmin
#db_user=32b68e3b57402121a5c59fd5fdae7f66
#db_user=ruyima_box_01
!-- \u5bc6\u7801[\u52a0\u5bc6] --
#db_passwd=bNVOqb7WKLX5Bjnw+LMv92taj25KOxDimXxILPQjw42wgv+1lHzOH8kr97xDwWdhpY67QuYCS7sWN4W46YbkFA==
#db_passwd=Tm5JSJD4TO8IbWxPgiNZuvHx+RelKYZ/pRf/Ak39/5nX8flKMOlnveDQjfIVC2d0oEpRANh1s92HbSEfcHNrkA==
db_passwd=654dcf2caf39d3ea1e69ab0d0019604b19c39e9e87d8c8f8883b3538f870f553
#Xboxes9@9DbAdmin
#654dcf2caf39d3ea1e69ab0d0019604b19c39e9e87d8c8f8883b3538f870f553
#Xboxes9@9DbAdmin
#kBjU1aunyUdhFL3omR8Vqxl/1dHImBTzdZNRL+Zz0EHbyRdw6hk88zKPNpzawIXQG5dO4Ha74VisfI5f7PddVA==
#db_passwd=KMfPbsplhK74g1JtaIorBPAcfSO4rE4sG6RiCBj+JDwUyMiZwhZkHy+amxyZbbv42mtxoRVTi8J6u03hR8TLJQ==
#//driverClassName : "com.mysql.jdbc.Driver",
#//url : "jdbc:mysql://127.0.0.1:3306/ruyima?useUnicode=true&characterEncoding=utf-8",
#//username : "root",
#//password : "root",

dao.js贴一下

这个是dbutil 的类 我找了一会 dao.js 我并没有发现package com.ruyima.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.ruyima.model.Tbl_cabinet;
import com.ruyima.model.BoxCode.tbl_cabinet;

public class DbUtil {
	
	private static final String LOCALURL ="jdbc:mysql://127.0.0.1:3306/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";
	private static final String TESTURL ="jdbc:mysql://www.i0033.com:3307/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";
	private static final String URL ="jdbc:mysql://101.200.182.90:3306/xboxes_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true";
	private static final String NEWURL ="jdbc:mysql://ruyimabox.mysql.rds.aliyuncs.com:3309/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";
	
	private static final String LOCALPWD = "root";
	private static final String TESTPWD = "root";
	private static final String PWD = "mysql";
	private static final String NEWPWD = "Pp010203";
	private static DataSource dataSource;
	
	{
		init();
	}

	private static void init() {

		try {
			
			Map<String, String> map = new HashMap<String, String>();
			// 向map中传递参数
//			String url = TESTURL;
			String url = URL;
			//String url = TESTURL;
			//"jdbc:mysql://www.i0033.com:3307/ruyima?useUnicode=true&characterEncoding=utf-8";
//			String username = "root";
			String username = "dbadmin";
			//String password = PWD;
			//String password = TESTPWD;
			String password = PWD;

			//map.put("url", "jdbc:mysql://115.28.224.50:3300/ruyima?useUnicode=true&characterEncoding=utf-8");// 数据库地址
			//map.put("url", "jdbc:mysql://www.i0033.com:3307/ruyima?useUnicode=true&characterEncoding=utf-8");// 数据库地址
			
			//map.put("username", "root");// 用户名
			//map.put("password", "Pp010203");// 密码
			
			map.put("url", "jdbc:mysql://101.200.182.90:3306/xboxes_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=true");// 数据库地址
			map.put("username", "dbadmin");// 用户名
			map.put("password", "Xboxes9@9DbAdmin");// 密码
			
			
			dataSource = DruidDataSourceFactory.createDataSource(map);
			
		} catch (Exception e) {
			
			Logger.getLogger(DbUtil.class).error(e);
			
		}
	}

	public static Dao dao() {

		if (dataSource == null) {
			init();
		}

		return new NutDao(dataSource);

	}
	
	public static Connection connect() {
		
		Connection conn=null;
		try{
		
		   conn=dataSource.getConnection();
		}catch(SQLException e ){
			
		    Logger.getLogger(DbUtil.class).error(e);
			
		}
		return conn;
	}
	
	public static void main(String[] args) {
		String sql = "select * from ";
		
	}

}

找dao.json试试, 还有就是@IocBy也贴一下

这个是我刚从原来的开发人员 要来的db.js
var ioc = {
	// 读取配置文件
	conf : {
		type : "org.nutz.ioc.impl.PropertiesProxy",
		fields : {
			paths : [ "etc/" ]
		}
	},
	dataSource : {
		factory : "$conf#make",
		args : [ "com.alibaba.druid.pool.DruidDataSource", "oracle." ],
		type : "com.alibaba.druid.pool.DruidDataSource",
		events : {
			create : "init",
			depose : 'close'
		}
	},
	dao : {
		type : "org.nutz.dao.impl.NutDao",
		args : [ {
			refer : "dataSource"
		} ]
	},
	zMongo : {
		args : [ {java:"$conf.get('mongodb.user')"}, {java:"$conf.get('mongodb.password')"}, {java:"$conf.get('mongodb.IP')"}, {java:"$conf.getInt('mongodb.port')"}, {java:"$conf.get('mongodb.instance')"} ], // 这里填仲裁服务的ip
		factory : "org.nutz.mongo.ZMongo#me"
	},
	zMoDB : {
		args : [ {java:"$conf.get('mongodb.instance')"} ],
		factory : "$zMongo#db"
	},
	zMoCo : {
		args : [ {java:"$conf.get('mongodb.collection')"} ],
		factory : "$zMoDB#c"
	}
};

args : [ "com.alibaba.druid.pool.DruidDataSource", "oracle." ]

读取的是 oracle.开头的配置信息,找一下相关的properties文件

PS: 记得把密码隐藏一下

我想问一下我本地的jdk 和jre tomcat 都是7.0 的 这个和框架冲突吗 另外 项目拿过来的时候 他本身用的8.0的tomcat

不好意思我看错了 这个是我本地项目的dao。js
//数据库连接信息配置
var ioc = {
	//配置慢查询
	statFilter : {
		type : "com.alibaba.druid.filter.stat.StatFilter",
		fields:{
			slowSqlMillis:3000,
			logSlowSql:true
		}
	},
	dataSource : {
		type : "com.alibaba.druid.pool.DruidDataSource",
		fields : {
			driverClassName : {java : '$conf.get("db_driver")'},
            url : {java : '$conf.get("db_url")'},
            username : {java : '$conf.get("db_user")'},
            password : {java : '$conf.get("db_passwd")'},
//			driverClassName : 'com.mysql.jdbc.Driver',
//            url : 'jdbc:mysql://test.ruyigui.com:3339/ruyima?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull',
//            username : 'rymtest',
//            password :'hg92104GuGH4S9rqoKFUED0JIZt3DsZQLGZaKeY2qHA+LEZVT14Qj2JzhYucTvVzcx8WmFsDaiwVv0Jq5FDs2Q==',
			// 初始化连接大小
			initialSize : 1,
			// 连接池最大使用连接数量
			maxActive : 20,
			// 连接池最小空闲
			minIdle : 1,
			// 获取连接最大等待时间
			maxWait : 60000,
			//打开监控|加密|日志
			filters:"stat,log4j,config",
			//注入慢查询
			proxyFilters:[{java:'$statFilter'}],
			//
			connectionProperties:"config.decrypt=true"
		},
		events : {
			depose : "close"
		}
		
	},
	dao : {
		type : "org.nutz.dao.impl.NutDao",
		args : [ {
			refer : "dataSource"
		} ]
	}
};
connectionProperties:"config.decrypt=true"

删掉这一行就可以写明文密码了

添加回复
请先登陆
回到顶部