从 Maven 原型创建 grails 项目

发布于 2024-10-17 23:06:40 字数 660 浏览 3 评论 0原文

当我尝试使用原型创建 Mavenized Grails 1.3.6 项目时:

mvn archetype:generate -DarchetypeGroupId=org.grails 
-DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.6 
-DgroupId=example -DartifactId=my-app 
-DarchetypeRepository=http://repo1.maven.org/maven2

我收到错误

[错误]执行目标失败 org.apache.maven.plugins:maven-archetype-plugin:2.0:生成 (默认-cli)在项目上 Standalone-pom:所需的原型 不存在 (org.grails:grails-maven-archetype:1.3.6)

我检查了 存储库和版本 1.3.6 确实存在。此外,如果我将上面命令中的版本 1.3.6 替换为 1.3.2,它就可以工作。

When I try to create a Mavenized Grails 1.3.6 project using the archetype:

mvn archetype:generate -DarchetypeGroupId=org.grails 
-DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.6 
-DgroupId=example -DartifactId=my-app 
-DarchetypeRepository=http://repo1.maven.org/maven2

I get the error

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:2.0:generate
(default-cli) on project
standalone-pom: The desired archetype
does not exist
(org.grails:grails-maven-archetype:1.3.6)

I've checked the repository and version 1.3.6 does exist. Moreover, if I replace version 1.3.6 in the command above with 1.3.2, it works.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

睫毛溺水了 2024-10-24 23:06:40

运行mvn archetype:generate(交互模式)并选择选项286

286:远程-> grails-maven-archetype (Grails 项目的 Maven 原型。)

一般来说,我遇到的麻烦比使用 Maven 原型的解决方案要多得多:S。

Run mvn archetype:generate (interactive mode) and select option 286

286: remote -> grails-maven-archetype (Maven archetype for Grails projects.)

In general, I've had way more troubles than solutions with maven archetypes :S.

冷…雨湿花 2024-10-24 23:06:40

我不知道您的特定配置发生了什么,但我运行了您在那里列出的确切命令,并且它构建成功。因为我猜测这与您之前关于如何指定依赖项的问题有关,所以我怀疑您更关心 pom 文件的内容,而不是实际弄清楚原型发生了什么,我将发布 pom.xml原型为我生成的文件。

<?xml version="1.0" encoding="utf-8"?>
<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>example</groupId>
  <artifactId>my-app</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>

  <name>A custom grails project</name>
  <description>A custom grails project</description>
  <url>http://www.myorganization.org</url>

  <properties>
    <grails.version>1.3.6</grails.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-bootstrap</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.codehaus.gpars</groupId>
          <artifactId>gpars</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.gant</groupId>
          <artifactId>gant_groovy1.7</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.gparallelizer</groupId>
          <artifactId>GParallelizer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.gant</groupId>
          <artifactId>gant_groovy1.6</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ivy</groupId>
          <artifactId>ivy</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-crud</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.grails</groupId>
          <artifactId>grails-docs</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
        </exclusion>
        <exclusion>
          <groupId>radeox</groupId>
          <artifactId>radeox</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-digester</groupId>
          <artifactId>commons-digester</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.persistence</groupId>
          <artifactId>persistence-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-gorm</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-digester</groupId>
          <artifactId>commons-digester</artifactId>
        </exclusion>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-commons-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>antlr</groupId>
          <artifactId>antlr</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-test</artifactId>
      <version>${grails.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.1.2</version>
    </dependency>

    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

    <!-- Grails defaults to Ehache for the second-level Hibernate cache. -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>3.3.1.GA</version>
        <exclusions>
          <!-- See http://www.slf4j.org/faq.html#IllegalAccessError -->
          <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
          </exclusion>

          <!-- We are pulling in ehcache-core below -->
          <exclusion>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
          </exclusion>
        </exclusions>
    </dependency>

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>1.7.1</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- For ease of development and testing, we include the HSQLDB database. -->
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>1.8.0.10</version>
    </dependency>

    <!-- Use Log4J for logging. This artifact also pulls in the Log4J JAR. -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>

    <!-- Needed in the case of AOP usage -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.6.8</version>
    </dependency>

    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.6.8</version>
    </dependency>

    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
    </dependency>

    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>

    <dependency>
      <groupId>commons-pool</groupId>
      <artifactId>commons-pool</artifactId>
      <version>1.5.3</version>
    </dependency>

  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <repositories>
      <!-- Required to get hold of javassist:javassist -->
    <repository>
      <id>jboss.org</id>
      <name>jboss.org</name>
      <url>http://repository.jboss.com/maven2/</url>
    </repository>
  </repositories>

  <build>
    <pluginManagement />

    <plugins>
      <plugin>
        <groupId>org.grails</groupId>
        <artifactId>grails-maven-plugin</artifactId>
        <version>${grails.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>init</goal>
              <goal>maven-clean</goal>
              <goal>validate</goal>
              <goal>config-directories</goal>
              <goal>maven-compile</goal>
              <goal>maven-test</goal>
              <goal>maven-war</goal>
              <goal>maven-functional-test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>tools</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>${java.version}</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>

I don't know what's going on with your particular configuration, but I ran the exact command you listed there and it built successfully. Since I'm guessing this is related to your previous question about how to specify dependencies, I suspect that you care more about the contents of the pom file than actually figuring out what's going on with the archetype, I'll post the pom.xml file that the archetype generated for me.

<?xml version="1.0" encoding="utf-8"?>
<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>example</groupId>
  <artifactId>my-app</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>

  <name>A custom grails project</name>
  <description>A custom grails project</description>
  <url>http://www.myorganization.org</url>

  <properties>
    <grails.version>1.3.6</grails.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-bootstrap</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.codehaus.gpars</groupId>
          <artifactId>gpars</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.gant</groupId>
          <artifactId>gant_groovy1.7</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.gparallelizer</groupId>
          <artifactId>GParallelizer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.gant</groupId>
          <artifactId>gant_groovy1.6</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ivy</groupId>
          <artifactId>ivy</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-crud</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.grails</groupId>
          <artifactId>grails-docs</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
        </exclusion>
        <exclusion>
          <groupId>radeox</groupId>
          <artifactId>radeox</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-digester</groupId>
          <artifactId>commons-digester</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.persistence</groupId>
          <artifactId>persistence-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-gorm</artifactId>
      <version>${grails.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-launcher</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-digester</groupId>
          <artifactId>commons-digester</artifactId>
        </exclusion>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-commons-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>antlr</groupId>
          <artifactId>antlr</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-test</artifactId>
      <version>${grails.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.1.2</version>
    </dependency>

    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

    <!-- Grails defaults to Ehache for the second-level Hibernate cache. -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>3.3.1.GA</version>
        <exclusions>
          <!-- See http://www.slf4j.org/faq.html#IllegalAccessError -->
          <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
          </exclusion>

          <!-- We are pulling in ehcache-core below -->
          <exclusion>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
          </exclusion>
        </exclusions>
    </dependency>

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>1.7.1</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- For ease of development and testing, we include the HSQLDB database. -->
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>1.8.0.10</version>
    </dependency>

    <!-- Use Log4J for logging. This artifact also pulls in the Log4J JAR. -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>

    <!-- Needed in the case of AOP usage -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.6.8</version>
    </dependency>

    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.6.8</version>
    </dependency>

    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
    </dependency>

    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>

    <dependency>
      <groupId>commons-pool</groupId>
      <artifactId>commons-pool</artifactId>
      <version>1.5.3</version>
    </dependency>

  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <repositories>
      <!-- Required to get hold of javassist:javassist -->
    <repository>
      <id>jboss.org</id>
      <name>jboss.org</name>
      <url>http://repository.jboss.com/maven2/</url>
    </repository>
  </repositories>

  <build>
    <pluginManagement />

    <plugins>
      <plugin>
        <groupId>org.grails</groupId>
        <artifactId>grails-maven-plugin</artifactId>
        <version>${grails.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>init</goal>
              <goal>maven-clean</goal>
              <goal>validate</goal>
              <goal>config-directories</goal>
              <goal>maven-compile</goal>
              <goal>maven-test</goal>
              <goal>maven-war</goal>
              <goal>maven-functional-test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>tools</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>${java.version}</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
赠意 2024-10-24 23:06:40

grails 2 的新 Maven 原型即将推出。请参阅 MAVEN-162

New maven archetype for grails 2 will be available soon. See MAVEN-162

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文