【问题标题】:ActiveMQQueue cannot be resolved to a type spring-boot-sampleActiveMQQueue 无法解析为 spring-boot-sample 类型
【发布时间】:2018-01-17 00:58:53
【问题描述】:

我是 java 新手。我正在研究 Spring Boot 示例 example

我正在尝试做 spring-boot-sample-activemq。 我的 pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <!-- <groupId>org.springframework.boot</groupId> -->
    <!-- <artifactId>spring-boot-samples</artifactId> -->
    <!-- <version>2.0.0.BUILD-SNAPSHOT</version> -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
</parent>
<groupId>sample.activemq</groupId>
<artifactId>spring-boot-sample-activemq</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<name>Spring Boot ActiveMQ Sample</name>
<dependencies>
    <!-- Compile -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-activemq</artifactId>
    </dependency>
    <!-- Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我在下面的 java 类中遇到错误(ActiveMQQueue 无法解析为类型)

src/main/java/sample/activemq/SampleActiveMQApplication.java

package sample.activemq;

import java.util.Queue;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms;

@SpringBootApplication
@EnableJms
public class SampleActiveMQApplication {

@Bean
public Queue queue() {
    return new ActiveMQQueue("sample.queue");
}

public static void main(String[] args) {
    SpringApplication.run(SampleActiveMQApplication.class, args);
}

 }

还有两个与Consumer and Producer classes中完全相同的类

【问题讨论】:

    标签: java spring maven spring-boot


    【解决方案1】:

    终于解决了我的问题

    运行 mvn dependency:purge-local-repository 以删除所有依赖项并强制重新下载。

    【讨论】:

      【解决方案2】:

      或者你可以在你的 pom.xml 中使用它

      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jms</artifactId>
          <version>5.1.3.RELEASE</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-10
        • 2016-01-18
        • 2017-02-17
        • 2018-02-10
        • 2015-10-22
        • 1970-01-01
        相关资源
        最近更新 更多