Dynamic Web Project 的例子

来源:互联网 发布:淘宝怎么解除绑定手机 编辑:程序博客网 时间:2024/06/06 08:26

准备用Spring、SpringMVC、Hibernate架构做一个登录的例子,同时也是我第一次尝试用实体类生成表

1.配置好server后,新建一个Dynamic  Web Project ,取名demo

2.导入Spring ,hibernate等框架要用到的jar包

3,配置:




没有找到可以注入的UserDao 类型的bean,心想bean没有纳入Spring的管理,于是改变配置文件的位置


org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.gacinfo.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}


改变位置后发现database.properties中的键值对不能够供Spring的配置文件使用,应该先搞清楚一个问题,那就是auction中,是如何让Spring的配置文件读到了database.properties。


org.springframework.beans.factory.BeanDefinitionStoreException: 

Invalid bean definition with name 'dataSource' defined in file [E:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\demo\WEB-INF\classes\applicationContext-hibernate.xml]: Could not resolve placeholder 'database.driverClassName'


仍然出错,先看看是不是路径和拼写错误,再看看是不是配置了多个placeHolder

结果发现改错文件了,改成了auction中的applicationContext.xml



14:08出错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\demo\WEB-INF\classes\applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [hibernate/hibernate.cfg.xml] cannot be resolved to URL because it does not exist



在建表时出错:

No identifier specified for entity: com.gacinfo.domain.User

解决之道:给该实体类对应的表指定主键

当务之急:如何指定主键? @Id 即可


为什么现在连表也没有生成?

怎么解决路径的问题?



The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.6.0_19/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_19/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_19/bin/../jre/lib/i386;.;C:\Program Files\Java\jdk1.6.0_19\bin;C:\Program Files\Java\jdk1.6.0_19\jre\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows7Master;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\TortoiseSVN\bin


按照网上的解决方案,下了一个tcnative-1.dll文件,放在了C:\Windows\system32,结果

An incompatible version 1.1.2 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17,唉,这个问题先放这里吧,据网上说,只要下载一个高版本,问题就能得以解决


[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:demo' did not find a matching property.

通过网上的设置解决 (控制台中的server才有general属性,Project Explorer指的就是左边的窗口)


java.lang.IllegalArgumentException: Document base E:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\demo does not exist or is not a readable directory