简体   繁体   English

将Java Web应用程序迁移到Spring Boot吗?

[英]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. 我正在考虑修改现有的Java Web应用程序(带有web.xml和applicationContext.xml文件以及Spring 2.5)以使用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. 我知道我将需要创建一个@Configuration文件来声明所有bean(以消除applicationContext.xml文件),但是我希望获得一些更多的见解。 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. 将Spring Boot依赖项添加到pom.xml或gradle文件中。
  2. Define all the XML beans using Java Configuration by @Bean 通过@Bean使用Java配置定义所有XML bean
  3. Define Spring Security if used through Java Configuration 如果通过Java配置使用,请定义Spring Security
  4. Add application.properties to resources directory and defines all the configuration values like database host,username,password etc 将application.properties添加到资源目录,并定义所有配置值,例如数据库主机,用户名,密码等
  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. 您可能还会有一些其他依赖项,例如Spring Security。 If your application uses Spring Security you have to provide java configuration for it. 如果您的应用程序使用Spring Security,则必须为其提供Java配置。 http://www.baeldung.com/spring-boot-security-autoconfiguration 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 https://spring.io/blog/2014/01/30/migrating-from-spring-framework-3-2-to-4-0-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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