如何在基于 Maven 的项目中使用 war
how to use war in a maven based project
我想在我的项目中使用 war 文件。你认为我可以在基于 Maven 的项目中做到这一点吗?我应该在 pom.xml 处编写或定义一些内容才能做到这一点吗?
可以向 pom.xml 添加外部 jar。但是是否可以将外部 war 添加到 pom.xml 并使用它的 类 就像我们将 jar 用作库一样???
type
元素可以用来提供依赖类型,类可以使用
<xs:element name="type" minOccurs="0" type="xs:string" default="jar">
<xs:annotation>
<xs:documentation source="version">4.0.0</xs:documentation>
<xs:documentation source="description">
The type of dependency. This defaults to jar. While it usually represents the extension on
the filename of the dependency, that is not always the case. A type can be mapped to a different
extension and a classifier.
The type often correspongs to the packaging used, though this is also not always the case.
Some examples are jar, war, ejb-client and test-jar.
New types can be defined by plugins that set
extensions to true, so this is not a complete list.
</xs:documentation>
</xs:annotation>
</xs:element>
示例:
<dependency>
<groupId>project-group</groupId>
<artifactId>war-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
我不知道从技术方面是否可行,但我会避免它。相反,将要重用的 类 放入 jar 项目并从所有 war 项目中引用该 jar。
我想在我的项目中使用 war 文件。你认为我可以在基于 Maven 的项目中做到这一点吗?我应该在 pom.xml 处编写或定义一些内容才能做到这一点吗?
可以向 pom.xml 添加外部 jar。但是是否可以将外部 war 添加到 pom.xml 并使用它的 类 就像我们将 jar 用作库一样???
type
元素可以用来提供依赖类型,类可以使用
<xs:element name="type" minOccurs="0" type="xs:string" default="jar">
<xs:annotation>
<xs:documentation source="version">4.0.0</xs:documentation>
<xs:documentation source="description">
The type of dependency. This defaults to jar. While it usually represents the extension on
the filename of the dependency, that is not always the case. A type can be mapped to a different
extension and a classifier.
The type often correspongs to the packaging used, though this is also not always the case.
Some examples are jar, war, ejb-client and test-jar.
New types can be defined by plugins that set
extensions to true, so this is not a complete list.
</xs:documentation>
</xs:annotation>
</xs:element>
示例:
<dependency>
<groupId>project-group</groupId>
<artifactId>war-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
我不知道从技术方面是否可行,但我会避免它。相反,将要重用的 类 放入 jar 项目并从所有 war 项目中引用该 jar。