我尝试启动hsqldb服务器以进行开发使用。我有hsqldb依赖:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.4</version>
</dependency>
我有构建exec-maven-build:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.hsqldb.server.Server</mainClass>
<arguments>
<argument>--database.0 file:target/monitoring</argument>
</arguments>
</configuration>
</plugin>
我启动mvn exec:java,服务器启动,我有这个错误:
[Server@6e9770a3]: [Thread[org.hsqldb.server.Server.main(),5,org.hsqldb.server.Server]]: Failed to set properties
org.hsqldb.HsqlException: no valid database paths: maformed database enumerator: server.database.0 mem:monitoring
我搜索代码,这个错误意味着什么,我在hsqldb代码中发现此页面上的错误=&gt; http://hsqldb.svn.sourceforge.net/viewvc/hsqldb/base/tags/2.2.5/src/org/hsqldb/server/Server.java?revision=4369&view=markup
private IntKeyHashMap getDBNameArray() {
final String prefix = ServerProperties.sc_key_dbname + ".";
final int prefixLen = prefix.length();
IntKeyHashMap idToAliasMap = new IntKeyHashMap();
Enumeration en = serverProperties.propertyNames();
for (; en.hasMoreElements(); ) {
String key = (String) en.nextElement();
if (!key.startsWith(prefix)) {
continue;
}
int dbNumber;
try {
dbNumber = Integer.parseInt(key.substring(prefixLen));
} catch (NumberFormatException e1) {
**printWithThread("maformed database enumerator: " + key);**
continue;
}
String alias = serverProperties.getProperty(key).toLowerCase();
if (!aliasSet.add(alias)) {
printWithThread("duplicate alias: " + alias);
}
Object existing = idToAliasMap.put(dbNumber, alias);
if (existing != null) {
printWithThread("duplicate database enumerator: " + key);
}
}
return idToAliasMap;
}
所以hsqldb用作关键所有参数:“没有有效的数据库路径:maformed database enumerator: server.database.0 mem:monitoring ”
所以它看起来像一个bug,或者我做错了什么?
好的,我找到了解决方案,我改变了为exec maven插件提供参数的方式。
来自:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.hsqldb.server.Server</mainClass>
<arguments>
<argument>--database.0 file:target/monitoring</argument>
</arguments>
</configuration>
</plugin>
到此:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.hsqldb.server.Server</mainClass>
<arguments>
<argument>--database.0</argument>
<argument>file:target/monitoring</argument>
</arguments>
</configuration>
</plugin>
它有效
答案 0 :(得分:9)
我改变了将参数传递给exec maven插件的方式
来自:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.hsqldb.server.Server</mainClass>
<arguments>
<argument>--database.0 file:target/monitoring</argument>
</arguments>
</configuration>
</plugin>
到此:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.hsqldb.server.Server</mainClass>
<arguments>
<argument>--database.0</argument>
<argument>file:target/monitoring</argument>
</arguments>
</configuration>
</plugin>
它有效
答案 1 :(得分:3)
我发现如果您需要从maven以服务器模式启动HSQL并继续运行集成测试,您必须使用maven-antrun-plugin和ant Java任务,因为exec-maven-plugin不支持分叉模式:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
</dependencies>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<target>
<property name="test_classpath" refid="maven.test.classpath" />
<java classname="org.hsqldb.server.Server"
fork="yes" spawn="yes">
<arg
line="--database.0 mem:test --dbname.0 test" />
<classpath>
<pathelement path="${test_classpath}" />
</classpath>
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
它假设您的hsqldb依赖项属于测试范围。