我刚刚开始尝试使用play框架并尝试理解在创建新项目时获得的这个默认应用程序.
据我所知,在加载localhost页面时,Application.index()由于路由文件中的规范,http get请求会进入并被定向到该方法?在该index()方法中,生成大量HTML代码并在Result对象中返回并传递给index.scala.html文件,该文件将其移交到main.scala.html更多html包围的位置.
现在,我不清楚一些事情:
在Application.java这个行return ok(index.render("Hello World!"));
索引属于views.html.*; 但这个包裹在哪里?我在API中找不到它:(
为什么我不能重命名index.scala.html文件?这个名字是一个惯例吗?
在index.scala.html文件本身:做@play20.welcome(message, style = "Java")什么?这是获得"欢迎来到Play 2.0"网站吗?再一次 - 我找不到play20的文档/ API条目:(
我希望,有人可以帮助我得到一个概述,因为我现在真的很困惑.. ^^我已经做了很多java,但根本没有网络编程,因此所有不同技术和语言的混合是此刻很奇怪!
在我的应用程序中,我使用hibernate-core-4.1.8 jar并希望将ehCache作为二级缓存.我目前使用的jar是ehcache-core-2.5.0.我把它放在我的WebContetn/WEB-INF/lib文件夹中,并将它放在类路径中.
我的hibernate.cfg.xml看起来像这样:
<hibernate-configuration>
<session-factory>
....
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
ehcache.xml放在JavaResources/src文件夹中:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">
<defaultCache
maxElementsInMemory="100000"
eternal="false"
timeToIdleSeconds="1000"
timeToLiveSeconds="1000"
overflowToDisk="false"
/>
</ehcache>
Run Code Online (Sandbox Code Playgroud)
运行我的应用程序时,找不到类org.hibernate.cache.ehcache.EhCacheRegionFactory:
java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.ehcache.EhCacheRegionFactory
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:444)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:275)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748)
at creator.controllers.MyFactory.<clinit>(MyFactory.java:18)
at creator.controllers.SchoolDAO.getList(SchoolDAO.java:98)
.....
Run Code Online (Sandbox Code Playgroud)