简体   繁体   English

为两个客户开发Java Web应用程序项目

[英]Java Web Application Project development for two clients

I'm developing a web-project based on Spring (MVC), Hibernate, PostgreSQL (using Maven). 我正在开发一个基于Spring(MVC),Hibernate,PostgreSQL(使用Maven)的Web项目。 Now I'm trying to get a new customer who requires some differences in several parts of the application. 现在我正在尝试让一个新客户在应用程序的几个部分中需要一些差异。 I've read the Maven Definitive Guide from Sonatype to get a feeling about Multi-modules Maven Projects but one of my most important questions has not been answered there: How can I share common view-components over several modules/projects and integrate them depending on the customer I want to build for? 我已经阅读了Sonatype的Maven权威指南来了解多模块Maven项目,但我最重要的问题之一还没有得到解答:如何在几个模块/项目上共享通用视图组件并根据它们进行集成对我想建立的客户? The Service-Layer is pretty clear but I can't figure out how to share jsp/jspf files and merge them with the custom files when building the specific customer-module (which then depends on the common-module). 服务层非常清楚但我无法弄清楚如何共享jsp / jspf文件并在构建特定客户模块时将它们与自定义文件合并(然后依赖于通用模块)。

How would you try to avoid just simply cloning the commonly used code? 您将如何避免仅仅克隆常用代码?

I can't figure out how to share jsp/jspf files and merge them with the custom files when building the specific customer-module (which then depends on the common-module). 我无法弄清楚如何共享jsp / jspf文件并在构建特定客户模块时将它们与自定义文件合并(然后依赖于通用模块)。

This looks like a good use case for Overlays . 这看起来像Overlays的一个很好的用例。

You can put common components in a library project and unpack them as needed using dependency:unpack or dependency:unpack-dependencies 您可以将常用组件放在库项目中,并根据需要使用依赖项解压缩它们:unpackdependency:unpack-dependencies

Eg you project layout would be like that: 例如,您的项目布局将是这样的:

root
 |____ common-lib (jar, contains common java code)
 |____ common-gui (jar, contains only non-java stuff like js, jsp, css etc) 
 |____ client1    (war)
 |____ client2    (war)

client1 and client2 would each have a regular compile dependency to common-lib, but only a provided dependency to common-gui (if you use dependency:unpack it doesn't have to be a project dependency at all) client1和client2都会对common-lib有一个常规的compile依赖关系,但只有一个provided对common-gui的dependency:unpack (如果你使用dependency:unpack它根本不必是项目依赖)

Now you'd add code like this to your client projects: 现在,您将向您的客户端项目添加这样的代码:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack-common-gui-elements</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.yourcompany</groupId>
                        <artifactId>common-gui</artifactId>
                        <version>${project.version}</version>
                        <type>jar</type>
                        <!--  war assembly directory -->
                        <outputDirectory>
                            ${project.build.directory}/${project.build.finalName}
                        </outputDirectory>
                        <includes>**/*.jsp,**/*.css,**/*.js</includes>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

That way you can re-use your components but you can always choose yourself which components you distribute to which client. 这样您就可以重新使用组件,但您可以随时选择将哪些组件分发给哪个客户端。

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

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