ElasticSearch搜不出来数据
原因:
没有上线,没有保存在elasticSearch里面
分词器的问题,搜索的单词没有被分词
可能搜索的单词没有被分成一个词语,比如:java大神,分词成:java,大神。搜索 “java大”,就肯定搜索不出来。
请求报错
业务逻辑有问题,打断点跟踪。
- 使用RabbitMQ出现问题
电脑用户名盘符是中文用户名
erlang环境安装出问题
- SpringBoot集成RabbitMQ
导包
<dependencies
>
<dependency
>
<groupId
>org.springframework.boot
</groupId
>
<artifactId
>spring-boot-starter-web
</artifactId
>
</dependency
>
<dependency
>
<groupId
>org.springframework.boot
</groupId
>
<artifactId
>spring-boot-starter-test
</artifactId
>
</dependency
>
<!--spirngboot集成rabbitmq--
>
<dependency
>
<groupId
>org.springframework.boot
</groupId
>
<artifactId
>spring-boot-starter-amqp
</artifactId
>
</dependency
>
</dependencies
>
<dependencyManagement
>
<dependencies
>
<dependency
>
<groupId
>org.springframework.boot
</groupId
>
<artifactId
>spring-boot-dependencies
</artifactId
>
<version
>2.0.5.RELEASE
</version
>
<type
>pom
</type
>
<scope
>import
</scope
>
</dependency
>
</dependencies
>
</dependencyManagement
>
配置yml连接参数
server:
port: 8000
spring:
application:
name: rabbitmq
rabbitmq:
host: 127.0.0.1
port: 5672
username: guest
password: guest
virtualHost: /
对RabbitMQ作配置写一个配置类
@Configuration
public class RabbitMQConfig
{
//三个队列名字 短信 邮件 站内信
//短信
private static final String QUEUE_SMS
= "queue_sms";
//邮件
private static final String QUEUE_EMAIL
= "queue_email";
//站内信
private static final String QUEUE_SYSTEM
= "queue_system";
//交换机名称
public static final String EXCHANGE_TOPIC
= "exchange_topic";
//定义交换机
@Bean
(EXCHANGE_TOPIC
)
public Exchange exchange
() {
return ExchangeBuilder.topicExchange
(EXCHANGE_TOPIC
).durable
(true
).build
();
}
//定义邮件队列
@Bean
(QUEUE_EMAIL
)
public Queue queueEmail
() {
return new Queue
(QUEUE_EMAIL, true
);
}
//定义短信队列
@Bean
(QUEUE_SMS
)
public Queue queueSMS
() {
return new Queue
(QUEUE_SMS, true
);
}
//定义队列
@Bean
(QUEUE_SYSTEM
)
public Queue queueSystem
() {
return new Queue
(QUEUE_SYSTEM, true
);
}
//将队列绑定到交换机
@Bean
public Binding bindingEmail
(@Qualifier
(QUEUE_EMAIL
) Queue queue,@Qualifier
(EXCHANGE_TOPIC
) Exchange exchange
){
return BindingBuilder.bind
(queue
).to
(exchange
).with
("message_Email").noargs
();
}
@Bean
public Binding bindingSms
(@Qualifier
(QUEUE_SMS
) Queue queue,@Qualifier
(EXCHANGE_TOPIC
) Exchange exchange
){
return BindingBuilder.bind
(queue
).to
(exchange
).with
("message_Sms").noargs
();
}
@Bean
public Binding bindingSystem
(@Qualifier
(QUEUE_SYSTEM
) Queue queue,@Qualifier
(EXCHANGE_TOPIC
) Exchange exchange
){
return BindingBuilder.bind
(queue
).to
(exchange
).with
("message_System").noargs
();
}
}
创建一个启动类
@SpringBootApplication
public class App
{
public static void main
(String
[] args
) {
SpringApplication.run
(App.class,args
);
}
}
发送消息
@RunWith
(SpringRunner.class
)
@SpringBootTest
(classes
= Application.class
)
public class Send
{
@Autowired
RabbitTemplate rabbitTemplate
;
@Test
public void test
() {
for (int i
= 0
; i
< 5
; i++
) {
String message
= "消息来了";
rabbitTemplate.convertAndSend
(RabbitMQConfig.EXCHANGE_TOPIC,
"inform.sms.email");
System.out.println
(message
);
}
}
}
接收消息
@Component
public class Rev
{
//监听队列
@RabbitListener
(queues
= RabbitMQConfig.QUEUE_EMAIL
)
public void listenter
(String msg, Message message, Channel channel
){
System.out.println
(msg
);
}
//监听duilie
@RabbitListener
(queues
= RabbitMQConfig.QUEUE_SYSTEM
)
public void listenter2
(String msg,Message message,Channel channel
){
System.out.println
(msg
);
}
//监听队列
@RabbitListener
(queues
= RabbitMQConfig.QUEUE_SMS
)
public void listenter3
(String msg,Message message,Channel
channel
){
System.out.println
(msg
);
}
}