小编Мак*_*кин的帖子

如何解决MyBatis selectForUpdate中的indexOutOfBounds错误?

我使用postgreSQL。这是我在 myBatisMapper 中的请求:

<select id="findByStatusAndIdentityAndPrvCode" parameterType="java.lang.String" resultMap="Request">
        select
        from req_tab
        where status in ('I', 'D', 'Q')
          and identity = #{identity}
          and prv_code = #{prvCode}
        limit 1 for update
    </select>
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

org.apache.ibatis.exceptions.PersistenceException: 
Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
The error may exist in ru/infogate/dao/mapper/ReqMapper.xml
The error may involve ru.infogate.dao.mapper.ReqMapper.findByStatusAndIdentityAndPrvCode
The error occurred while handling results
SQL: select         from req_tab         where status in ('I', 'D', 'Q')           and identity = ?           and prv_code = ?         limit …
Run Code Online (Sandbox Code Playgroud)

java mybatis spring-mybatis mybatis-sql mybatis-mapper

4
推荐指数
1
解决办法
5095
查看次数

如何在Rabbit中设置x-dead-letter-exchange?

这是我的豆子:

    @Bean
    public Queue igSmev3ListenerQueue() {
        Map<String, Object> args = new HashMap<>();
        args.put("x-dead-letter-exchange", rabbitIgSmev3DlxProperties.getExchangeName());
        args.put("x-dead-letter-routing-key", rabbitIgSmev3DlxProperties.getRoutingKey());
        return new Queue(rabbitIgSmev3ListenerProperties.getQueueName(), true, false, false, args);
    }

    @Bean
    public Queue igSmev3DlxQueue() {
        return new Queue(rabbitIgSmev3DlxProperties.getQueueName(), true, false, false);
    }
Run Code Online (Sandbox Code Playgroud)

以下是 application.yml 设置:

listener:
  vhost: /
  exchangeName: igSmev3Listener
  queueName: igSmev3-ListenerQueue
  routingKey: igSmev3-Listener
dlx:
  vhost: /
  exchangeName: igSmev3Dlx
  queueName: igSmev3-DlxQueue
  routingKey: igSmev3-Dlx
Run Code Online (Sandbox Code Playgroud)

我目前的错误:

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but …
Run Code Online (Sandbox Code Playgroud)

java rabbitmq spring-rabbit rabbitmq-exchange

2
推荐指数
1
解决办法
1947
查看次数

为什么最后会打印异常的堆栈跟踪?

这是我的简单测试代码:

class Scratch {
    public static void main(String[] args) {
        try {
            System.out.println("Line 1");
            throw new RuntimeException();
        } catch (RuntimeException e) {
            e.printStackTrace();
        } finally {
            System.out.println("Line 2");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

运行后我会得到这个:

Line 1
Line 2
java.lang.RuntimeException
    at Scratch.main(scratch_4.java:5)

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

我以为“finally”代码必须最后执行,但事实并非如此。是什么原因?

java exception stack-trace

2
推荐指数
1
解决办法
370
查看次数