发表于: 2017-07-25 21:24:36
2 1044
今天:
mybatis警告错误修改:
&---->"&"还是出现error building sqlsession
mybatis教程的url如下:3306后跟数据库名结束
修改后:
还是有警告:
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
无语。。。
spring项目结构
程序及运行结果
解决了错误
class path resource [beans.xml] cannot be opened because it does not exist
因为beans.xml文件存放在项目工程中的路径不对,
当放在java程序所在包中时,程序报错
当beans.xml文件放在src目录下时,程序正常运行
但是Console显示了两行红色的日期和信息有关于beans.xml的载入和org.springframework.context.support.ClassPathXmlApplicationContext的刷新,不知道为什么会出现这个。
在Class Path Resource中找不到beans.xml是因为这个xml文件在建工程的时候默认没有放在src下面,但是用Class Path Resource是在当前目录也就是我这个java文件所在的src目录下进行寻找。因此把这个xml文件移动到src目录下面就ok了。
a 用ApplicationContext ctx=new ClassPathXmlApplicationContext()也是这样是从当前路径寻找,xml文件应在当前目录下。
b 用FileSystemXmlApplicationContext,它根据指定的路径来进行寻找,要把路径写完整。现在xml路径在src文件夹下。那就要写:ApplicationContext ctx=new FileSystemXmlApplicationContext("src/applicationContext.xml");
FileSystemXmlApplicationContext也可以采用加上classpath:前缀(这个时候xml要放在当前目录也就是src下)
ApplicationContext ctx=new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
c 加上file:把路径写全(用这个方法xml可以放任意地方)
ApplicationContext context = new FileSystemXmlApplicationContext("file:E:/JAVADEMO/HelloSpring/src/com/jinhege/beans.xml");
ApplicationContext context = new ClassPathXmlApplicationContext("file:E:/JAVADEMO/HelloSpring/src/com/jinhege/beans.xml");
最简单的方法是把xml文件放在src文件下。
听老大的LIVE对于自己自学JAVA不看好了。。。。。。自己基础差,这么自学,毕业后能找得到工作吗?自己开始怀疑了。。。。
评论