小编Mik*_*icz的帖子

mvn clean没有依赖

我有一个第三方罐子,这是我们项目所必需的.它在中央maven存储库中不可用,因此我使用maven-install-plugin在构建期间在本地安装jar.我将"安装文件"目标绑定到"验证"阶段,这大部分都有效.pom.xml文件摘录如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <id>install-myartifact</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <file>${basedir}/lib/myartifact-1.2.3.jar</file>
                        <groupId>com.example</groupId>
                        <artifactId>myartifact</artifactId>
                        <version>1.2.3</version>
                        <packaging>jar</packaging>
                        <generatePom>true</generatePom>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>myartifact</artifactId>
        <version>1.2.3</version>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

然而,有一个问题.我们的大多数开发人员和我们的Jenkins安装都运行"mvn clean install"."验证"阶段不是"干净"生命周期的一部分,并且清理莫名其妙地要求运行所有依赖关系.所以第一次有人运行这个版本时,它不起作用.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MyModule
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory C:\svn\trunk\mymodule\target
Downloading: http://nexusserver.local:8080/nexus/content/groups/public/com/example/myartifact-1.2.3.pom
[INFO] Unable to find resource 'com.example:myartifact:pom:1.2.3' in repository central (http://central)
[INFO] ------------------------------------------------------------------------
[ERROR] …
Run Code Online (Sandbox Code Playgroud)

maven-2 maven

6
推荐指数
2
解决办法
3946
查看次数

用于Java类的特定于版本的实现的模式

所以这是我的难题.我正在编写一个需要处理旧版本应用程序的工具.我有应用程序的代码,但不能改变任何类.为了从我们的数据库中提取信息,我有一个由Hibernate填充的各种DTO.它使用我们的应用程序版本1.0的数据对象,巧妙地命名为DataObject.以下是DTO课程.

public class MyDTO {  
    private MyWrapperClass wrapper;  

    public MyDTO(DataObject data) {
        wrapper = new MyWrapperClass(data);
    }
}
Run Code Online (Sandbox Code Playgroud)

DTO通过Hibernate查询实例化,如下所示:

select new com.foo.bar.MyDTO(t1.data) from mytable t1
Run Code Online (Sandbox Code Playgroud)

Now, a little logic is needed on top of the data object, so I made a wrapper class for it. Note the DTO stores an instance of the wrapper class, not the original data object.

public class MyWrapperClass {

    private DataObject data;

    public MyWrapperClass(DataObject data) {
        this.data = data;
    }

    public String doSomethingImportant() { ... …
Run Code Online (Sandbox Code Playgroud)

java spring design-patterns hibernate

5
推荐指数
1
解决办法
597
查看次数

标签 统计

design-patterns ×1

hibernate ×1

java ×1

maven ×1

maven-2 ×1

spring ×1