Spring yandex qatools postgresql嵌入式。是否需要在机器上安装postgres?
使用的依赖项:ru.yandex.qatools.embedded postgresql-embedded-2.5.jar 代码:Spring yandex qatools postgresql嵌入式。是否需要在机器上安装postgres?,spring,postgresql,junit,Spring,Postgresql,Junit,使用的依赖项:ru.yandex.qatools.embedded postgresql-embedded-2.5.jar 代码: final File dbDir = new File("/tmp/embeddedinstallation" + port); String postgresInfo = embeddedPostgres.start(EmbeddedPostgres.cachedRuntimeConfig((dbDir).toPath()), "localhost", port
final File dbDir = new File("/tmp/embeddedinstallation" + port);
String postgresInfo = embeddedPostgres.start(EmbeddedPostgres.cachedRuntimeConfig((dbDir).toPath()), "localhost", port, "db", "uname", "psswd", new ArrayList<String>());
参考:
它并没有提到postgres需要安装在机器上。
但我看到代码访问命令:
package ru.yandex.qatools.embed.postgresql;
import ru.yandex.qatools.embed.postgresql.config.PostgresConfig;
public enum Command {
Postgres("postgres", PostgresExecutable.class),
InitDb("initdb", InitDbExecutable.class),
CreateDb("createdb", CreateDbExecutable.class),
PgCtl("pg_ctl", PgCtlExecutable.class),
Psql("psql", PsqlExecutable.class),
PgDump("pg_dump", PsqlExecutable.class),
PgRestore("pg_restore", PsqlExecutable.class),
Createuser("createuser", PsqlExecutable.class),
;
它是否需要在机器上安装postgres,还是我做了一些不正确的事情?我想出来了,它确实会将postgres下载到指定的位置
/**
* Initializes runtime configuration for cached directory.
* If a provided directory is empty, postgres will be extracted into it.
*
* @param cachedPath path where postgres is supposed to be extracted
* @return runtime configuration required for postgres to start
*/
public static IRuntimeConfig cachedRuntimeConfig(Path cachedPath) {
final Command cmd = Command.Postgres;
final FixedPath cachedDir = new FixedPath(cachedPath.toString());
return new RuntimeConfigBuilder()
.defaults(cmd)
.artifactStore(new PostgresArtifactStoreBuilder()
.defaults(cmd)
.tempDir(cachedDir)
**.download(new PostgresDownloadConfigBuilder()
.defaultsForCommand(cmd)
.packageResolver(new PackagePaths(cmd, cachedDir))
.build()))**
.build();
}
/**
* Initializes runtime configuration for cached directory.
* If a provided directory is empty, postgres will be extracted into it.
*
* @param cachedPath path where postgres is supposed to be extracted
* @return runtime configuration required for postgres to start
*/
public static IRuntimeConfig cachedRuntimeConfig(Path cachedPath) {
final Command cmd = Command.Postgres;
final FixedPath cachedDir = new FixedPath(cachedPath.toString());
return new RuntimeConfigBuilder()
.defaults(cmd)
.artifactStore(new PostgresArtifactStoreBuilder()
.defaults(cmd)
.tempDir(cachedDir)
**.download(new PostgresDownloadConfigBuilder()
.defaultsForCommand(cmd)
.packageResolver(new PackagePaths(cmd, cachedDir))
.build()))**
.build();
}