Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vaadin JavaEE到Vaadin Spring的逐步迁移是否可能?_Java_Spring_Hibernate_Vaadin_Vaadin8 - Fatal编程技术网

Vaadin JavaEE到Vaadin Spring的逐步迁移是否可能?

Vaadin JavaEE到Vaadin Spring的逐步迁移是否可能?,java,spring,hibernate,vaadin,vaadin8,Java,Spring,Hibernate,Vaadin,Vaadin8,我们有一个现有的vaadin8javaeewebapp,它是从Tickets仪表板演示中改编和大量修改的。我们正在计划一个时间表,将应用程序迁移到使用Spring non-boot,并在下一个版本中采用MVC模型。然而,在阅读了Vaadin Spring文档并比较了当前应用程序、样本面包店应用程序Spring和框架8以及使用Hibernate 4和Spring 4的旧项目之间的源代码之后,我们仍然有一些关键问题需要帮助改进迁移方法: 当一些函数先迁移到Spring,然后在后续的次要版本中迁移其他

我们有一个现有的vaadin8javaeewebapp,它是从Tickets仪表板演示中改编和大量修改的。我们正在计划一个时间表,将应用程序迁移到使用Spring non-boot,并在下一个版本中采用MVC模型。然而,在阅读了Vaadin Spring文档并比较了当前应用程序、样本面包店应用程序Spring和框架8以及使用Hibernate 4和Spring 4的旧项目之间的源代码之后,我们仍然有一些关键问题需要帮助改进迁移方法:

当一些函数先迁移到Spring,然后在后续的次要版本中迁移其他函数时,是否可以逐步迁移?如果是,在进入较小的版本之前,除了下面的类之外,我应该首先修改/调整哪些类以适应Spring

我们已经确定,75%的应用程序使用复杂的本机select查询,25%使用CRUD操作。我们仍然坚持使用Hibernate,因为大多数开发团队都熟悉它。坚持使用DAO泛型方法封装实现(例如,还是只使用baker应用程序中的JPARepository接口)更好

我们正在将应用程序部署到Azure云中,并将TomEE Plume(相当于Tomcat的8.5版本)作为开始部署。是否应包括任何特殊设置以适应该部署

我们曾在瓦丁论坛上提出过关于逐步移民的问题,但没有得到任何答复:

在计划的迁移活动之后,我们的近期目标是:

使其模块化,并更容易合并后续功能,如动态数据路由、断路器/重新路由、电子邮件通知、国际化、在生产级别将可管理实例的数量保持在5-10个等

保持升级渠道的开放性,而不必在未来几年内从头重写所有内容,例如Java8到Java11,Framework8到Vaadin12

如上所述,这是为了在Azure云上运行MSSQL数据库和TomEE容器

我们已经做了一些初步的代码修改,包括:

修改主pom.xml并包含更好的maven评测,使用作为参考

将hibernate和spring设置移动到application.properties文件

添加application-context.xml并将其再次划分为application-context-dao.xml和application-context-service.xml,以使其易于管理

Web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<servlet>
    <servlet-name>SycardaDashboard2</servlet-name>
    <servlet-class>com.example.dashboard.DashboardServlet</servlet-class>
    <init-param>
        <param-name>UI</param-name>
        <param-value>com.example.dashboard.DashboardUI</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>SycardaDashboard2</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
application-context.xml

<beans>
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:application-development.properties</value>
                <value>classpath*:application-production.properties</value>
            </list>
        </property>

    </bean>
<import resource="classpath*:applicationContext-dao.xml" />
<import resource="classpath*:applicationContext-service.xml" />

<context:component-scan base-package="com.example.dashboard">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
<!-- Activates scanning of @Autowired -->
<context:annotation-config/>

<!-- Activates scanning of @Repository -->
<context:component-scan base-package="com.igi.sycarda.dashboard.dao"/>

<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" destroy-method="destroy">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan">
        <list>
            <value>com.example.dashboard.entities</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
            <prop key="current_session_context_class">thread</prop>

            <prop key="show_sql">${hibernate.show.sql}</prop>
            <prop key="format_sql">${hibernate.format.sql}</prop>
            <prop key="use_sql_comments">${hibernate.use.sql.comments}</prop>
        </props>
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>
application-dao-context.xml

<beans>
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:application-development.properties</value>
                <value>classpath*:application-production.properties</value>
            </list>
        </property>

    </bean>
<import resource="classpath*:applicationContext-dao.xml" />
<import resource="classpath*:applicationContext-service.xml" />

<context:component-scan base-package="com.example.dashboard">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
<!-- Activates scanning of @Autowired -->
<context:annotation-config/>

<!-- Activates scanning of @Repository -->
<context:component-scan base-package="com.igi.sycarda.dashboard.dao"/>

<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" destroy-method="destroy">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan">
        <list>
            <value>com.example.dashboard.entities</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
            <prop key="current_session_context_class">thread</prop>

            <prop key="show_sql">${hibernate.show.sql}</prop>
            <prop key="format_sql">${hibernate.format.sql}</prop>
            <prop key="use_sql_comments">${hibernate.use.sql.comments}</prop>
        </props>
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

首先,在迁移的第一周之后,我们预计应用程序仍然是90%的JavaEE,一到两个功能将在春季发布。在每周的更新之后,现有功能的数量将转移到使用Spring,直到它被完全整合。

这样的迁移是可能的。你有多个问题,我只回答其中两个

有可能逐步迁移吗?是的,这是可能的,你可以先把它放在最底层的中心——对于复杂的monolith,你的DAO和存储库。或者,您可以尝试将应用程序分割成小的逻辑单元,并尝试迁移这些单元。这种切片的例子是,如果我们有一个计算商品价格的电子商务网站服务。它是一个定义明确、易于隔离的服务。这样做还可以让您更好地了解如何模块化应用程序。有时,这种方法可能太难了,因为大型的巨石上的代码只是斯帕盖蒂的。 现有DAO的Spring数据使用和迁移。您不必使用spring数据。拥有DAO或手动编写的存储库是非常好的。在我看来,不需要付出额外的努力,也不需要为这种迁移做额外的工作。 在我看来,迁移过程中的主要目标应该是进行合理的模块化,并将整块体拆分为逻辑单元。我不是在谈论单独的可部署和微服务,没有必要走这么远。但逻辑上拆分它可能会为您提供迁移映射