我有一堆Spring bean,它们是通过注释从类路径中获取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
Run Code Online (Sandbox Code Playgroud)
在Spring XML文件中,定义了一个PropertyPlaceholderConfigurer:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我想将app.properites中的一个属性注入上面显示的bean中.我不能简单地做一些事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
因为PersonDaoImpl在Spring XML文件中没有特征(它是通过注释从类路径中获取的).我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
Run Code Online (Sandbox Code Playgroud)
但是我不清楚我如何访问我感兴趣的房产ppc?
假设我想为我的集成测试创建和使用H2数据库.
Maven有一个运行测试的命令:mvn test.
有没有办法告诉maven为测试启动H2数据库服务器并在完成后停止它?
我想这个工作类似于我如何通过Maven命令运行tomcat(mvn tomcat:run).
对不起,如果这个问题没有意义,我仍然围绕着新的概念.
我有一个多模块项目.
parent POM (1.0-SNAPSHOT) |-- module1 (1.0-SNAPSHOT) |-- module2 (1.0-SNAPSHOT) `-- module3 (1.0-SNAPSHOT)
当我执行mvn release时:准备它验证父POM是否有SNAPSHOT版本,并且所有相关模块都没有SNAPSHOT版本.如何自动将所有子模块从SNAPSHOT更新到下一个发行版本?
我想自动增加所有模块的版本.
log4j有一个属性,log4j.debug它将有助于向用户提供实际用于配置日志记录系统的配置文件的指示.
我无法找到与(否则更高级)Logback日志框架等效的东西.有没有办法在运行时打印(用于诊断目的),哪个配置文件Logback用于自举?
[编辑]为了澄清,我理想地喜欢一个不需要我修改配置文件本身的解决方案(例如,由于错误组装的第三方JAR可能被错误地拾取,并且在我的回溯配置之前XML).
在maven中,使用以下语法在pom中设置属性非常容易:
...
<properties>
<myValue>4.06.17.6</myValue>
</properties>
...
Run Code Online (Sandbox Code Playgroud)
现在我需要构建一个取决于我的pom版本的属性.为了创建属性,我想执行以下操作(java伪代码):
String[] parts = version.split("\\.");
String.format("V%s_%s_%s_P%s", splitted[0], splitted[1],splitted[2],splitted[3]);
// example: 4.06.17.6 => V_4_06_17_P6
Run Code Online (Sandbox Code Playgroud)
它应该是动态的,因为它在我们的存储库中用作标记名称,并且必须始终与工件的版本同步.
任何想法如何创建"动态"属性?
我想从一个依赖项中排除所有传递依赖项.在某些地方,我看到它建议使用通配符
<dependency>
<groupId>myParentPackage</groupId>
<artifactId>myParentProject</artifactId>
<version>1.00.000</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我收到警告:
'dependencies.dependency.exclusions.exclusion.groupId' for myParentPackage:myParentProject:jar with value '*' does not match a valid id pattern. @ line 146, column 30
Run Code Online (Sandbox Code Playgroud)
虽然声明本身是成功的:在我的构建中确实忽略了传递依赖.
我还发现了一个旧功能请求,确实要求此功能
所以现在我不知道这是否是我不应该使用的弃用功能,如果警告错误,或者功能还没有完全实现(我正在使用Maven 3.0.4)...有人知道更多吗?
我在Win 7上使用maven来构建应用程序.我使用exec插件来调用python脚本.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>create-dir</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>src/main/upgrade/create.py</executable>
<arguments>
<argument>ChangeSet.txt</argument>
</arguments>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我在构建项目时遇到以下错误.
Embedded error: Cannot run program "pathToScript/create.py" CreateProcess error=193, %1 is not a valid Win32 application
Run Code Online (Sandbox Code Playgroud)
我确实安装了python并添加到%PATH变量中.
如何修复它以使其独立于OS平台工作?
.:-编辑-:.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<executable>python</executable>
<workingDirectory>src/main/upgrade/</workingDirectory>
<arguments>
<argument>createChangeSet.py</argument>
</arguments>
</configuration>
<id>python-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我有一个项目配置为使用Maven构建和运行.该项目依赖于特定于平台的本机库,我使用此处的策略来管理这些依赖项.
本质上,特定平台的.dll或.so文件被打包到jar中,并通过标识目标平台的分类器推送到Maven服务器.然后,maven-dependency-plugin解包特定于平台的jar,并将本机库复制到目标文件夹.
通常我会mvn exec:java用来运行Java程序,但是exec:java在与Maven相同的JVM中运行应用程序,这会阻止我修改类路径.由于必须将本机依赖项添加到类路径中,因此我不得不使用mvn exec:exec.这是pom的相关片段:
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Djava.library.path=target/lib</argument>
<argument>-classpath</argument>
<classpath />
<argument>com.example.app.MainClass</argument>
</arguments>
</configuration>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
这适用于应用程序的默认配置,但我希望能够在命令行中指定一些可选参数.理想情况下,我想做这样的事情:
mvn exec:exec -Dexec.args="-a <an argument> -b <another argument>"
Run Code Online (Sandbox Code Playgroud)
不幸的是,指定exec.args变量会覆盖我在pom中的参数(这些参数是设置类路径并运行应用程序所必需的).有没有解决的办法?在命令行中指定一些可选参数而不覆盖我在pom中的内容的最佳方法是什么?
我已经阅读了Maven文档中的部分,但我还没有看到任何使用<ciManagement>项目POM中的标记的插件的证据.
我的问题是:
有谁知道SQL Server Reporting Services中两个Web服务端点ReportService2005.asmx和ReportExecution2005.asmx之间的区别是什么?有没有我可以通过的文章?谢谢.
maven ×5
java ×3
dependencies ×1
h2 ×1
logback ×1
maven-2 ×1
maven-3 ×1
multi-module ×1
properties ×1
python-2.7 ×1
spring ×1
sql-server ×1
ssrs-2008 ×1
testing ×1