我想在我的项目中使用war文件。你认为我可以在基于maven的项目中做到这一点吗?我应该在pom.xml上编写或定义一些东西才能做到这一点?
可以在pom.xml中添加外部jar。但是有可能向pom.xml添加外部战争并使用它们的类,比如我们使用jar作为库吗?
答案 0 :(得分:3)
我不知道是否可以从技术方面,但我会避免它。相反,将要重用的类放入jar项目中,并从所有war项目中引用该jar。
答案 1 :(得分:-1)
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>