1.@Value取不到值:
@Value取不到值引出的spring的2種配置文件applicationContext.xml和xxx-servlet.xml
項目中經常會用到配置文件,定義成properties的形式比較常見,爲了方便使用一般在spring配置文件中做如下配置:
<context:property-placeholder ignore-unresolvable="true" location="classpath*:/application.properties" />
這樣在程序代碼中直接用@Value(“${name}”)就能直接取到properties文件中定義的變量值.
其中,applicationContext.xml爲spring配置文件,xxx-servlet.xml爲spring-mvc配置文件。@Value取不到值的問題,現在的可以清楚由於Controller是定義在springmvc的servlet配置文件中的,查找,故只需要將placeholder重新在springmvc的配置中配置一遍,Controller中的@Value註解便能取到值了.
2.延遲加載的時候,報coudnt get session 的錯誤
在xml配置文件中將對應的controller地址加到spring mvc的管理中。
3.xxx type error
在生成的bean文件中,註解要麼全放在屬性域上面,要麼全放在getxxx()方法域上面,不能在一個bean中,存在兩種情況。
學習文章:
《hibernate註解》http://www.cnblogs.com/sevenlin/p/sevenlin_sprindatajpa20150725.html
《hibernate與jpa關係》http://blog.sina.com.cn/s/blog_5f1619e80100yoxz.html#cmt_2897777