我正在开发一个Spring应用程序,其中所有东西都配置了maven (在pom.xml
中)。我的应用程序使用PostgreSQL数据库,但是单元测试使用内存中的HSQLDB数据库.
我只是遇到了TEXT
列的问题,因为HSQLDB本机不支持它们。在我的实体类中:
private @Column(columnDefinition = "text") String propertyName;
这在Postgres中很好,但是HSQLDB生成了以下错误:type not found or user lacks privilege: TEXT
。该表没有创建,因此我的大多数测试都失败了。
我发现我需要激活PostgreSQL兼容性,以便通过将sql.syntax_pgs
设置为true
来使其工作。
我的问题是:我该把这个设置放在哪里?我想把它放在pom.xml
中,因为所有的东西都配置在那里,但我不知道在哪里。
例如,我有:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dspring.profiles.active=test</argLine>
</configuration>
</plugin>
我可以在这个设置中添加一个<argLine>
吗?
发布于 2016-09-24 06:29:04
添加hsqldb依赖项时,它使用默认连接属性。您可以根据需要在属性文件中或通过其他配置覆盖这些属性。您可以将"sql.syntax_pgs=true“设置为HSQLDB连接url。例如,在弹簧引导的情况下,这将如下所示。
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dspring.datasource.url=jdbc:hsqldb:mem:PUBLIC;sql.syntax_pgs=true</argLine>
</configuration>
</plugin>
发布于 2016-09-23 13:23:50
可以在数据资源配置中将其设置为给定的这里
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:PUBLIC;sql.syntax_pgs=true" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
https://stackoverflow.com/questions/39661332
复制相似问题