1) Does the project, containing the common entities, has a persistence.xml file? If so, how does it differ from the one in the other projects?
是.主要区别在于模型项目中的persistence.xml应该定义所有实体,并且web项目中的persistence.xml应该只引用模型项目JAR文件.否则,您将继续在persistence.xml文件中复制entites.
另一个可能的区别是模型项目中的那个应该使用资源本地事务类型,以便从项目内部进行单元测试(例如使用main()方法)非常容易. Web项目中的那些当然应该使用例如数据源. JTA.
2) How exactly are the commonly used entities referenced in the two projects? Do I use the tag in their persistence.xml for reference? And if so, would “lib/MyCommon.jar” be the right way to use, if MyCommin.jar is located in WEB-INF/lib?
是和否.< jar-file>是正确的方法,但你的文件名中有一个拼写错误,文件夹应该省略. lib文件夹通常仅在您拥有EAR并且JAR包含在EAR的lib文件夹中时使用.
MyCommon.jar
3) Does it make any difference if the application is deployed as a WAR or an exploded archive in JBoss 6?
没有.正确设计的Java API不依赖于本地磁盘文件系统,而只依赖于类路径.如果WAR被扩展,它使类路径没有区别.
4) When deployed within eclipse via addition to server runtime and publish, is there anything different from deploying outside eclipse?
从技术上讲,是的.功能上,没有.
5) Is the described way putting common entities in a separate project, creating a JAR and use that JAR in the other project a sensible way to handle the problem of sharing common entity classes or is there a better way?