Dynamic creation of beans in Spring

后端 未结 3 1361
面向向阳花
面向向阳花 2020-12-21 18:45

Is there a way in spring wherein we can read the fields of a bean from the DB table and create a complete bean class - with getters and setters on server startup????

3条回答
  •  鱼传尺愫
    2020-12-21 19:37

    1: Improve your accept-rate

    2: You might benefit from something like an ORM approach (Hibernate or JPA). Another slightly different approach that might suite you is the Active Record pattern as implemented in, forinstance, ActiveJDBC.

    Spring does not, in itself, offer anything like what you are after, but using spring-jpa together with Hibernate might get you a bit closer towards your goal. If, OTOH, you want auto-generated code you could also look at something like Spring-Roo

提交回复
热议问题