2013-03-24 93 views
2

我对当前项目使用maven。现在,我有一战的依赖:如何使用tomcat运行maven war依赖项:运行?

<dependency> 
    <groupId>org.dojotoolkit</groupId> 
    <artifactId>dojo-war</artifactId> 
    <version>1.8.1</version> 
    <type>war</type> 
    <scope>runtime</scope> 
</dependency> 

我没有任何问题,当我建立战争神器。对于这一点,我已经加入这个插件:

<plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>2.1.1</version> 
     <configuration> 
      <overlays> 
       <overlay> 
        <groupId>org.dojotoolkit</groupId> 
        <artifactId>dojo-war</artifactId> 
        <targetPath>js/dojo-1.8.1</targetPath> 
        <excludes> 
         <exclude>WEB-INF/**</exclude> 
         <exclude>META-INF/**</exclude> 
        </excludes> 
       </overlay> 
      </overlays> 
     </configuration> 
    </plugin> 

但是,当我运行下面的命令MVN我mvn tomcat7:run不能看到任何JavaScript资源。它看起来像战争依赖没有被添加。

有人可以帮我吗?

在此先感谢。

回答

0

欢迎来到Stack Overflow Emelendez。

你应该阅读这篇文章:http://webtide.intalio.com/2008/07/dojo-toolkit-maven-repository/

事实上,道场战的依赖,您可以添加一些文件到你的源代码,但你必须指定一些额外的行动,包括在最后的战争。

Maven中的依赖关系只能用你试图编译的语言(它并不是真的确切,但这里已经足够了)。如果你想添加zip/war/targz中包含的其他资源(文件,图像,javascript),你必须明确地提取它们。这就是在我以前提供的链接mentionned:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>unpack dojo</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>unpack</goal> 
      </goals> 
      <configuration> 
       <artifactItems> 
        <artifactItem> 
         <groupId>org.dojotoolkit</groupId> 
         <artifactId>dojo</artifactId> 
         <version>${project.version}</version> 
         <type>zip</type> 
        </artifactItem> 
       </artifactItems> 
       <outputDirectory>${project.build.directory}/dojo</outputDirectory> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

(请注意,我不知道,这个配置是确切的,你dependencie似乎根据你的pom.xml是道场,战争,不按照文档说的dojo)

这将提取dojo libs到输出目录,然后进入你的战争。