简体   繁体   中英

Migrate java web app to spring boot?

I am considering modifying an existing java web app (with web.xml and applicationContext.xml files and Spring 2.5) to use Spring Boot. What are the implications of this process? I know I will need to create an @Configuration file to declare all of the beans (to eliminate the applicationContext.xml files), but would love some additional insight. Any suggestions are appreciated!

Migration would take several steps. Some of them are:-

  1. Add Spring Boot dependencies to your pom.xml or gradle file.
  2. Define all the XML beans using Java Configuration by @Bean
  3. Define Spring Security if used through Java Configuration
  4. Add application.properties to resources directory and defines all the configuration values like database host,username,password etc
  5. Define your views inside resources/templates

You've to include all the dependencies required. Some of the dependencies are:-

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!-- Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

You could have some other dependencies too like Spring Security. If your application uses Spring Security you have to provide java configuration for it. http://www.baeldung.com/spring-boot-security-autoconfiguration

https://spring.io/blog/2014/01/30/migrating-from-spring-framework-3-2-to-4-0-1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM