无法在Spring

时间:2015-06-18 12:04:52

标签: spring maven datasource placeholder jrebel

我遇到了jdbc动态属性configurer的问题。我试着解释究竟是什么问题。

当我在我的服务器(Weblogic 10.3.3)中部署应用程序之后{I} {我正在执行{1}}时,一切正常,并且所有应用程序都正常工作。但是,每天早上,当我尝试重新部署相同的应用程序时,会显示如下错误消息:

mvn clean install

Error creating bean with name 'path.to.my.bean.JDBCPropertiesFactoryBean#6015a10' defined in class path resource [spring/configuration/placeholder-jdbcproperties.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [ SELECT A.COLUMN1 || '.' || P.COLUMN2, COLUMN3 FROM T_TABLE_WITH_PROPERTIES${application.version} P, T_TABLE_WITH_PROPERTIES_2 G WHERE G.ID = P.ID ]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: invalid character 来自maven pom.xml:

application.version

豆子是:

<properties>
  ...
  <application.version>MyVersion</application.version>
  ...
</properties>

所以,每天早上我都要用maven重建,然后循环重新开始。

附加信息:我也尝试使用JRebel,但我不确定问题出在哪里,也许这是相关的。

提前致谢。

更新:

这是我如何生成<bean id="jdbcPlaceholderConfig" class="path.to.my.bean.DefaultPropertyPlaceholderConfigurer"> <!-- Class to extend PropertyPlaceholderConfigurer --> <property name="ignoreUnresolvablePlaceholders" value="true"/> <property name="properties"> <bean class="path.to.my.bean.JDBCPropertiesFactoryBean"> <!-- Class to extend PropertiesFactoryBean --> <property name="query"> <value> SELECT A.COLUMN1 || '.' || P.COLUMN2, COLUMN3 FROM T_TABLE_WITH_PROPERTIES${application.version} P, T_TABLE_WITH_PROPERTIES_2 G WHERE G.ID = P.ID </value> </property> <property name="dataSource" ref="ref.to.datasource.bean"/> </bean> </property>

rebel.xml

我刚刚意识到使用<build> ... <plugins> <plugin> <groupId>org.zeroturnaround</groupId> <artifactId>jrebel-maven-plugin</artifactId> <version>1.1.5</version> <configuration> <relativePath>../../</relativePath> <rootPath>PATH\TO\MY\SIS_VOB</rootPath> <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml> <alwaysGenerate>true</alwaysGenerate> </configuration> <executions> <execution> <id>generate-rebel-xml</id> <phase>process-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ,当我执行<executions>...<goal>generate</goal>...</executions>时,如果没有mvn clean install,则始终会生成jrebel:generate个文件,因此我可能需要删除执行标记,并使用rebel.xml生成rebel.xml个文件一次,然后编辑jrebel:generate并再次执行rebel.xml

这是正确的吗?

感谢。

更新解决方案:

这是pom.xml中maven jrebel插件的最终版本:

mvn clean install

创建rebel.xml:

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.zeroturnaround</groupId>
      <artifactId>jrebel-maven-plugin</artifactId>
      <version>1.1.5</version>
      <configuration>
        <relativePath>../../</relativePath>
        <rootPath>PATH\TO\MY\SIS_VOB</rootPath>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
        <alwaysGenerate>true</alwaysGenerate>
      </configuration>
      <!-- executions tag out! to not regenerate files always -->
    </plugin>
  </plugins>
</build>

然后,如果我们想要,我们可以修改mvn jrebel:generate 文件,如果我们想要排除某些文件,例如rebel.xml,就像Henri的回答一样。

就是这样!

1 个答案:

答案 0 :(得分:1)

如果您正在使用JRebel进行资源过滤,则可能会发生这种情况,因为应用程序从项目工作目录中查找未过滤形式的bean的xml(按照rebel.xml)。 / p>

要解决此问题,您需要更新该模块的rebel.xml,为该特定XML文件添加排除 - 请参阅here

Example

相关问题