0

これを POM ファイルに追加しようとしています。これは、Hello World プログラムの POM ファイルの例です。

<!-- Import the Common Annotations API (JSR-250), we use provided scope 
     as the API is included in JBoss AS 7 -->
  <dependency>
     <groupId>org.jboss.spec.javax.annotation</groupId>
     <artifactId>jboss-annotations-api_1.1_spec</artifactId>
     <scope>provided</scope>
  </dependency>

実行すると失敗します。バージョン番号がありませんと表示されます。1.0 などのバージョンを追加しても、まだ失敗します。私はPOMファイルとmavenにかなり慣れていないので、説明があれば役に立ちます。

私のPOMファイル:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.unihub.app</groupId>
  <artifactId>unihub</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>unihub</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
<!--Import the Servlet API using provided scope as the JARs are already included in Jboss7-->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>
     <build>
      <!-- Set the name of the war, used as the context root when the app 
         is deployed -->
      <finalName>unihub</finalName>
      <plugins>
               <plugin>
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <version>7.3.Final</version>
         </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.1</version>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
        </plugin>
       </plugins>
   </build>
</project>
4

1 に答える 1

2

Maven の依存関係については、利用可能なバージョンを知る必要があります。

使用しているリポジトリを参照するか、Web 上で検索できます。

例: http://mvnrepository.com/artifact/org.jboss.spec.javax.annotation/jboss-annotations-api_1.1_spec

1.0.1.Final が有効なバージョンであることを示します。

于 2013-02-20T07:00:16.833 に答える