简体   繁体   中英

Cannot find org.springframework.integration.Message when using spring-boot-starter-integration

I'm using Spring boot and want to use the starter pom for Spring Integration.

In my POM I have:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.3.RELEASE</version>
    <relativePath/>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-integration</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

This pulls in 4.3.6 versions of Spring Integration jars and 4.3.5 of Spring Framework jars. In one of my own classes I'm trying to use Message:

import org.springframework.integration.Message;

public Object doThings(Message<?> message) {
}

but I can't seem to locate Message. In an older version of Spring integration it was in spring-integration-core.jar but it's not there in this version. Has it moved or has something changed? I've checked the docs and it's still referenced so I assume I'm looking in the wrong place - but core sounds like the place it should be in to me! What am I doing wrong?

A few core concepts of Spring Integration have been merged inside Spring Core between versions 3.0 and 4.0, and org.springframework.integration.Message is one of them.

In your code sample, replacing

import org.springframework.integration.Message;

public Object doThings(Message<?> message) {
}

by

import org.springframework.messaging.Message;

public Object doThings(Message<?> message) {
}

will do the trick.

For a more exhaustive list of affected classes and interfaces, have a look at the 3.0 to 4.0 Spring Integration migration guide

It ok for me with using this version

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.1.9.RELEASE</version>
</dependency>

and

import org.springframework.messaging.Message;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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