Webapp boot code in Tomcat

I am developing a Java webapp using Spring, Spring Security, Tomcat and MySQL. Now I am still in the phase where I make quite frequent changes to the database, as well as recreating the database to clear the test data. Ultimately, this will not be a problem, but is there a way to create a bean or code that runs to download Webapp? I would like to be able to use the IoC functionality to use the same, e.g.PasswordEncoderwhich my application uses to populate the original user accounts. In addition, I would like this script to create a database if it does not exist, etc. Is there any way to do this? Is there a better way than I suggest? I'm not married to the algorithm I just described, but this is the best way I can imagine to convey what I'm looking for.

Thanks in advance!

+3
source share
3 answers

Spring, ContextLoaderListener ApplicationContext. ApplicationContext , JPA Hibernate, jdbc

+3

liquibase. . Liquibase Spring bean: liquibase.spring.SpringLiquibase, .

+3

bean ApplicationListener.

, ContextRefreshedEvent

, beans , , .

the disadvantage is that this event is fired on initialization and on updating

ContextRefreshedEvent Published when the ApplicationContext is initialized or updated. Initialized here means that all beans are loaded, single-threaded instances are pre-created and the ApplicationContext is ready to use.

+1
source

Source: https://habr.com/ru/post/1765707/


All Articles