简体   繁体   English

Spring Integration JDBC插入语句

[英]Spring Integration JDBC Insert Statement

I'm new to Spring integration. 我是Spring集成的新手。 I'm trying to write a POJO for my database. 我正在尝试为数据库编写POJO。 I'm getting this error, which I don't quite understand. 我收到此错误,我不太了解。 Is my syntax wrong, or am I using channels/adapters/gateways in the wrong manner? 我的语法是否错误,或者我以错误的方式使用通道/适配器/网关?

no declaration can be found for element int-jdbc:outbound-channel-adapter . 找不到元素int-jdbc:outbound-channel-adapter

Here is my code: 这是我的代码:

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:integration="http://www.springframework.org/schema/integration"
    xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
        http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
        http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


<int-jdbc:outbound-gateway id="transmissionGateway"
    query="insert into MSRB_RTRS (Sec_ID, SourceLoad_ID, TradeDate) values (:Sec_ID, 
    :SourceLoad_ID, :TradeDate)"
    data-source="rmsa">

</int-jdbc:outbound-gateway>

public interface DatabaseService {
    public void insertMessage(int secID, int sourceLoadID, String tradeDate);
}

@Inject
DatabaseService service;

service.insertMessage(-1, -1, "20170830");

Here are my dependencies: 这是我的依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-jdbc</artifactId>
        <version>4.3.5.RELEASE</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.0.8112.100</version>
    </dependency>
    <dependency>
        <groupId>com.companyname</groupId>
        <artifactId>spring-boot-common</artifactId>
        <version>1.0.0.COMMON-SBCOMMON-14</version>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>


    <!-- End -->
    <dependency>
        <groupId>com.companyname</groupId>
        <artifactId>companyname-spring-core-spring-4</artifactId>
        <version>1.1-M20160505-01</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.5</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

The spring integration jdbc pom contains 春季集成jdbc pom包含

  <dependency>
      <groupId>org.springframework.integration</groupId>
      <artifactId>spring-integration-core</artifactId>
      <version>4.3.5.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>4.3.4.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>19.0</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>

spring-integration-jdbc-2.2.xsd 弹簧集成-JDBC-2.2.xsd

Don't put a version on the schema import. 不要在架构导入中放置版本。 It has to match the version you are using (4.3). 它必须与您使用的版本(4.3)相匹配。

If you leave the version off, Spring will resolve the right version for you (see /META-INF/spring.schemas in the jar). 如果您不使用该版本,Spring将为您解决正确的版本(请参见jar中的/META-INF/spring.schemas )。

http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd

In any case; 任何状况之下; everything (jars, schema) must have matching versions. 所有内容(jar,模式)都必须具有匹配的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM