Soa architecture splits the presentation layer and service layer into independent projects [transformation 1]

Keywords: Spring xml Eclipse Maven

Delete the web project reference first


image.png

Then cut the E3 manager web in the folder to the same level as E3 parent.


image.png

After shearing


image.png

And then start the transformation in eclipse.

e3-manager pom.xml

< module > E3 Manager Web < / module > delete

Then change E3 manager service to war package


image.png

image.png

And then report an error because there is no web.xml


image.png

Then update Maven update to avoid error

Then import E3 Manager Web

image.png

image.png

Because E3 manager is the same level as E3 parent, you need to modify the dependency.

image.png

Now the implementation class that does not depend on service depends on the service interface

image.png

Then add E3 manager service spring to pom.xml of E3 manager web.


    <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>

Under E3 Manager Web Src / main / resources

image.png

Copy to E3 manager service Src / main / resources

The spring mvc.xml under the spring package is deleted.

Configure web.xml to load spring container after deletion

    <!-- Load spring container -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/applicationContext-*.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

Transformation of E3 Manager Web

Delete conf under src/main/resources delete applicationContext-dao.xml under mybatis spring package
applicationContext-service.xml
applicationContext-trans.xml

Leave only springmvc.xml

Configure web.xml

<!-- Solve post Random code -->
    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <!-- springmvc Front end controller for -->
    <servlet>
        <servlet-name>e3-manager</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!-- contextConfigLocation Not required if not configured contextConfigLocation, springmvc The default profile for is: WEB-INF/servlet Of name+"-servlet.xml" -->
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>e3-manager</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

Posted by s_r_elliott on Wed, 23 Oct 2019 15:08:34 -0700