JAVA 고정(static) 메서드에서 주입 호출 서비스 레이어(Dao 레이어) 의존

4439 단어 java
package com.coboriel.doorlook.utils;

import com.xxx.demo.entity.HotelUser;
import com.xxx.demo.mapper.HotelUserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class GetPayload {
    private static final Logger log = LoggerFactory.getLogger(GetPayload.class);

    @Autowired
    private HotelUserMapper hotelUserMapper;

    public static GetPayload getPayload;

    @PostConstruct
    public void init(){
        getPayload = this;
        getPayload.hotelUserMapper = this.hotelUserMapper;
    }


    public static String testPost(String mobile) {

        HotelUser hotelUser = getPayload.hotelUserMapper.getAllByMobile(mobile);

    }

}

좋은 웹페이지 즐겨찾기