2012-05-14 26 views
1

我正在尝试使用Mavan和maven-grails-plugin构建我的grails项目。运行Maven目标时的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

有谁知道我怎么能得到这个使用建设环境设置,而不是发展的?

在此先感谢

回答

1

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

0

不知道该插件的版本。 也许

<grailsEnv>build</grailsEnv> 

是一个更好的配置属性?