【发布时间】:2015-03-19 06:39:32
【问题描述】:
在我们的项目中,我们为 REST 层、EJB 层和域(实体)层设置了单独的模块。
这是对我们 REST 层的依赖:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
</dependency>
<!-- Resteasy Server Cache -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cache-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
</dependency>
Q1: 是否存在提供所有这些的 org.jboss.resteasy 的单一依赖项?有没有简化的可能?是否应该明确声明所有这些依赖项?如果没有,RestEasy 默认提供什么?事实上,我使用 JBoss AS 6。所以这些依赖项仅用于编译时。反正他们的范围是provided。
我们的域层也是如此:
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>provided</scope>
</dependency>
Q2:为什么在我们的 pom.xml 中显式声明这些?对休眠的依赖不应该为其他依赖提供默认值。
Q3 以下是一种有效的重构方式(使用Jboss bom)吗?在父 pom.xml 中有一个依赖项,每个模块都只是从父级继承。这样子 pom.xml 就简化了,简短了。这有什么缺点?我会得到我在上面的每个 REST 和域层中明确提供的所有依赖项吗?
<dependency>
<groupId>org.jboss.bom.eap</groupId>
<artifactId>jboss-javaee-6.0-with-resteasy</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
【问题讨论】:
标签: hibernate maven jakarta-ee jboss resteasy