Is it necessary to use some design patterns in SpringMVC projects?

< H2 > background < / H2 >

in order to be compatible with a variety of businesses, I want to use some design patterns in the project for ease of management.
for example, I need to create a user and return userid,. Each business is created in a different way.
I chose Adapter pattern, but I found that new classes are often needed under the management of springmvc, and at this time, some spring tags in this class are invalid.
here is the code I used to create the user:

Interface

public interface IPlatformSendPay {

    public abstract Object sendPayInA(Object object);
    public abstract Object sendPayInB(Object object);

}

parent

public class PlatformSendPay  {
    private Object obj;

    @Resource
    private OpenPaymentDao openPaymentDao;

    public PlatformSendPay(Object obj) {
        this.obj = obj;
    }

    public Object getUserIdInA(){
        JidouOrderData jidouOrderData = (JidouOrderData) obj;

        int stationId = jidouOrderData.getStation_id();
        //openPaymentDao@ResourcePlatformSendPayspring
        Integer userId = openPaymentDao.getIdentifyUser(jidouOrderData.getIdentifyId(), "1000000013");
        if (ObjectUtils.isEmpty(userId)){
           //todo:
        }
        return userId;
    }


}

subclass

public class SendPay extends PlatformSendPay implements IPlatformSendPay{

    public SendPay(Object obj) {
        super(obj);
    }

    @Override
    public Object sendPayInA(Object object) {
        return getUserIdInA();
    }
    
    @Override
    public Object sendPayInB(Object object) {
        return getUserIdInB();
    }

}

this is my implementation class, the @ Service tag in springmvc

  //
  SendPay sendPay = new SendPay(jidouOrderData);
  int userId = (int) sendPay.getUserIdInA();

  //
  SendPay sendPay = new SendPay(JdOrderData);
  int userId = (int) sendPay.getUserIdInB();

questions

1.PlatformSendPay Why is spring binding unsuccessful? How can I bind successfully? In
2.springmvc, do you use such design patterns as little as possible? In the method in the object, the variable used has a spring tag, but in the case of new, will this be invalid?


< H1 > pattern problems < / H1 >

the so-called design pattern is a summary of common object relationships, which actually includes relationships with almost all possible common objects. It would be great if you could successfully bypass all design patterns and write programs. In fact, this is a natural process, and there is no need to model for the sake of patterns.

< H1 > Why spring binding is not successful < / H1 >

in the case of autoassembly, it is not possible to assemble manual new objects, because spring autoassembly only occurs in the initialization scan phase. In your case, it is recommended to adopt the method of object inheritance, where different sub-objects implement different logic, rather than the same object produces different logic due to different construction parameters.


for example, I need to create a user and return userid,. Each business is created in a different way.

isn't this a typical factory model? The output is consistent and returns the userid, creation process based on the business. A simple factory will be fine.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b365d7-4ec71.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b365d7-4ec71.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?