【问题标题】:Grails environment config when running Maven goals运行 Maven 目标时的 Grails 环境配置
【发布时间】:2012-05-14 10:49:29
【问题描述】:

我正在尝试使用 Mavan 和 maven-grails-plugin 构建我的 grails 项目。

我的 pom.xml 文件中的插件配置如下所示:

<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>
        <configuration>
            <env>build</env>
        </configuration>
      </execution>
    </executions>
  </plugin>

我的 DataSource.groovy 配置如下所示:

environments {
development {
    dataSource {
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:mysql://localhost/mydb?useUnicode=yes"
        username = "dev"
        password = "dev"
    }
    hibernate {
        show_sql = true
    }
}
build {
    dataSource {
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:mysql://localhost/mydb?useUnicode=yes"
        username = "remote"
        password = "remote"
    }
}

问题是当我运行mvn clean package 时,它会尝试使用开发环境设置而不是构建环境设置连接到数据库。

如您所见,我尝试使用元素中的标签指定构建环境。根据这个问题-> Maven Grails Plugin Environment

有谁知道我怎样才能让它使用构建环境设置而不是开发设置?

提前致谢

【问题讨论】:

    标签: grails maven build grails-maven


    【解决方案1】:

    调用maven时添加-Dgrails.env=build命令行参数。

    【讨论】:

      【解决方案2】:

      不知道是什么版本的插件。 也许是

      <grailsEnv>build</grailsEnv>
      

      是更好的配置属性吗?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-03
        • 2017-10-22
        • 1970-01-01
        • 1970-01-01
        • 2013-07-13
        • 1970-01-01
        • 2019-06-09
        • 1970-01-01
        相关资源
        最近更新 更多