小编Tan*_*ect的帖子

设置java系统属性-D或System.setProperty()的最佳做法是什么?

我需要为我正在处理的RMI应用程序设置代码库,并且首先使用它成功完成了

try{
  ResourceBundle config = ResourceBundle.getBundle("myApp");
  String codeBaseUrl = config.getString("codeBaseUrl");
  System.setProperty("java.rmi.server.codebase", codeBaseUrl);
} catch (Exception e) {
  e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

然后使用

java -Djava.rmi.server.codebase=http://192.168.1.1/path/to/codebase ...
Run Code Online (Sandbox Code Playgroud)

在命令行上.

这两种方法都允许在不需要重新编译的情况下更改代码库,但System.setProperty方法允许将代码库并入属性文件并使用相同的启动命令.

我读过的大部分教程/文档都使用-D方法让我相信这被认为是最佳实践,但我一直无法找到解释为什么我应该使用的另一个.

-D被认为是设置系统属性(如代码库)的最佳实践,它会带来哪些好处/它会避免哪些陷阱?

java

9
推荐指数
1
解决办法
7326
查看次数

禁用Maven-remote-resources-plugin的资源过滤

我正在尝试使用maven-remote-resources-plugin在多模块maven项目中的模块之间共享大量资源。不幸的是,共享二进制资源在绑定过程中被破坏了,大概是通过过滤。

我确信在此阶段会发生损坏,因为从本地存储库中提取共享资源jar包含损坏的二进制文件。

是否可以关闭对Maven-remote-resources-plugin的过滤?

目前,我共享资源模块中的pom看起来像

<build>
  <plugins>
    <plugin>
       <artifactId>maven-remote-resources-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>bundle</goal>
           </goals>
         </execution>
       </executions>
       <configuration>
         <includes>
           <include>**/*</include>
         </includes>
       </configuration>
     </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.3</version>
  </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

filtering maven maven-resources-plugin

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

标签 统计

filtering ×1

java ×1

maven ×1

maven-resources-plugin ×1