??xml version="1.0" encoding="utf-8" standalone="yes"?>
q是异常的第一行,按以往的经验,W一行应该就是问题所在,但是实际上,从这行来看你Ҏ(gu)不知道错在哪里?br />
后面接下来的是:(x)
Error creating bean with name 'basicProcessingFilter'
Cannot resolve reference to bean 'authenticationManager'
while setting bean property 'authenticationManager';
nested exception is Error creating bean with name 'authenticationManager'
Cannot resolve reference to bean 'casAuthenticationProvider'
while setting bean property 'providers' with key [0];
nested exception is : Error creating bean with name 'casAuthenticationProvider'
Cannot resolve reference to bean 'statelessTicketCache'
while setting bean property 'statelessTicketCache';
nested exception is: Error creating bean with name 'statelessTicketCache'
Error setting property values;
nested exception is
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1:
TypeMismatchException:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
Error creating bean with name 'authenticationManager'
Cannot resolve reference to bean 'casAuthenticationProvider'
while setting bean property 'providers' with key [0];
nested exception is
Error creating bean with name 'casAuthenticationProvider'
Cannot resolve reference to bean 'statelessTicketCache' while setting bean property 'statelessTicketCache';
nested exception is
Error creating bean with name 'statelessTicketCache'
Error setting property values;
nested exception is
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
Error creating bean with name 'casAuthenticationProvider'
Cannot resolve reference to bean 'statelessTicketCache'
while setting bean property 'statelessTicketCache';
nested exception is
Error creating bean with name 'statelessTicketCache'
Error setting property values;
nested exception is PropertyAccessExceptionsException;
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1:TypeMismatchException:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
Error creating bean with name 'statelessTicketCache'
Error setting property values;
nested exception is PropertyAccessExceptionsException;
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
PropertyAccessExceptionsException;
nested PropertyAccessException details (1) are:
PropertyAccessException 1:
ypeMismatchException:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
上面的内Ҏ(gu)我将重复信息LQƈ分块后的l果?br />
从报错机制可以看出来Qspring出现异常不同于普通的java异常Q我们查异常的习(fn)惯一般是xW一行,但是sping恰恰相反Q要在sping中查错,你必d解他Q因为spring的嵌套层ơ比较多Q它报错是从最高层报vQ然后逐层往下,每个层次都会(x)要报错,直到最l出错的地方Q因此查sping的错必须逐层分解到最底层Q那里才是真正出错的地方?br />
OKQ现在看出来?jin),真正错误的原因是Q?br />
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'
我出现这个错误的原因是用了(jin)Acegi 1.0.5Q它本n自带?jin)ehcache 1.2.4.jar
但是我同时还使用?jin)hibernate3.1,从Eclipse导入hibernate3.1Ӟ会(x)导入ehcache 1.1.jarQ因为hibernate本n也要使用EHCacheQ但是版本不同?/p>
import java.io.*;
import java.util.regex.*;
public class Ip
{
private static void fileIO(File f)
{
String strLine;
// 调用执行本程序的操作pȝ的标准换行符Q意味着跨^?br> String line = System.getProperty("line.separator");
try
{
// 输入?br> FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
// 输出?br> FileOutputStream fos = new FileOutputStream("c://b.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter bw = new BufferedWriter(osw);
/*
* 创徏一个模式对象, 模式中编辑的正则表达式匹配分别是(200-249|250-255|001-199) 以匹配一个IP地址
*/
Pattern pattern = Pattern
.compile("((2[0-4]d|25[0-5]|[01]?dd?).){3}(2[0-4]d|25[0-5]|[01]?dd?)");
// 声明模式适配?br> Matcher matcher;
// 循环d文g中的每一?br> while ((strLine = br.readLine()) != null)
{
/*
* String调用replaceAllҎ(gu)匚w一个正则表辑ּ扑ֈ一个位|,然后替换成逗号
*/
strLine = strLine.replaceAll("(?<=d)s+", ",");
// 用适配器加载一行字W串Qƈ匚w模式
matcher = pattern.matcher(strLine);
// 如果在一行中能找到匹配的字符串则循环
while (matcher.find())
{
// 取一行中W一个能匚w的子字符?br> String buf = matcher.group();
// ?."分割成数字,然后分别补零Q再合ƈ
strLine = matcher.replaceAll(change(buf));
// 输入一行到文gQ但不包括换行符
bw.write(strLine);
// 输入行分割符Q即换行W?br> bw.write(line);
}
}
// 关闭输入?br> br.close();
// 关闭输出?br> bw.close();
}
// 捕获原始文g未找到异?br> catch (FileNotFoundException e)
{
System.out.println("原始文g未找?);
}
// 捕获IO异常
catch (IOException e)
{
e.printStackTrace();
}
}
// 此方法用来接收一个分割出来的一个数字,不?位的补零后返?br> private static String fill(String str)
{
// 不3位的补零
while (str.length() < 3)
{
str = '0' + str;
}
// q回补零后的字符?br> return str;
}
private static String change(String buf)
{
// ~冲字符?br> String temp;
// l果q回字符?br> String ret;
// ?."分割Q存入字W串数组
String[] str = buf.split(".");
// W一个数字不需要在前面?."
ret = fill(str[0]);
// 从第2个数字开始,l每个数字前面分别再加上"."Qƈ且不的补零
for (int i = 1; i < str.length; i++)
{
// 调用fillҎ(gu)l不?位的数字补零
temp = fill(str[i]);
// 每个数字加点后从新组装成一?br> ret = ret + "." + temp;
}
// q回l果字符?br> return ret;
}
// E序入口
public static void main(String[] args)
{
// d始文?br> File f = new File("c://a.txt");
// 原始文件传入fileIOҎ(gu)Q按要求加工
fileIO(f);
}
}