我有一个FTP客户端类,它返回指向文件的InputStream.我想用BufferedReader逐行读取文件.问题是,客户端以二进制模式返回文件,并且该文件具有ISO-8859-15编码.
我们的Hudson安装显示了Selenium报告的非常简洁的版本:
Selenium Report Result
numTestPasses 2
numTestFailures 0
Run Code Online (Sandbox Code Playgroud)
我知道应该可以通过Hudson查看完整的报告,并跟踪测试的开发.但是怎么样?
我们的代码有这样的:
@Resource(name = "java:comp/resource/foo/bar/ONE_QUEUE")
private Queue queue;
Run Code Online (Sandbox Code Playgroud)
但是,在一个部署方案中,队列注释应如下所示:
@Resource(name = "java:comp/resource/foo/bar/SECOND_QUEUE")
private Queue queue;
Run Code Online (Sandbox Code Playgroud)
我想选择与Maven构建配置文件一起使用的名称.
我有什么选择?
我们的应用程序可以为多个应用程序服务器构建,并在多个环境中使用.
应使用Maven配置文件指定应用程序服务器和目标环境的类型.编译代码时,每个配置文件类型中只应存在一个.所有配置文件都会导致执行一个或多个mavent-antrun-plugin复制任务,以便将正确的设置文件包含到生成的JAR中.
下面是pom.xml文件的一部分.包括AS简档"oracle"的一部分,以及环境概况"开发"的一部分.目的是,为了创建可以在开发环境中部署到Oracle AS的JAR,使用两个配置文件开关编译代码mvn -P oracle,development
AS配置文件还有其他任务(下面未显示),这些任务必须在环境配置文件任务发生之前执行(这就是配置文件具有不同阶段的原因).
我的问题是,Maven拒绝在两个选定的配置文件中执行任务.
mvn -Poracle就像它应该的那样工作.那样做mvn -Pdevelopment.但是,mvn -Poracle,development导致只执行oracle配置文件中的任务.如果oracle profile的antrun插件中的所有任务都被注释掉,那么开发配置文件中的任务就会被执行.
我的问题是:*为什么Maven拒绝在这两个配置文件中执行ant任务?*有没有办法来解决这个问题?
结合配置文件(oracle-development,jboss-development等)对我们来说不是一个选项,因为这个模块是一个更大项目的一部分,需要修改其他几个项目.
我们使用目前的Maven 2.2.0.
<profile>
<id>oracle</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy .../>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
...jboss, glassfish profiles...
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy .../>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
...production, test profiles...
Run Code Online (Sandbox Code Playgroud)
我在用户和标签之间有m:n的关系.一个用户可以拥有m个标签,一个标签可以属于n个用户.表看起来像这样:
USER:
ID
USER_NAME
USER_HAS_TAG:
USER_ID
TAG_ID
TAG:
ID
TAG_NAME
Run Code Online (Sandbox Code Playgroud)
假设我需要选择所有标签为"apple","orange"和"banana"的用户.使用SQL(MySQL DB)实现此目的的最有效方法是什么?
我有一个看起来像这样的实体:(我正在编写网页,所以我为任何错误道歉)
@Entity
public class Entity {
@Id
private Long id;
private String field;
// Insert getters and setters here...
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用反射来操纵它:
Long id = 1;
Entity entity = myDao.getEntity(id);
entity.setField("set directly");
Field[] fields = entity.getClass().getDeclaredFields();
for (Field f : fields) {
if (f.getName().equals("field")) {
f.setAccessible(true);
f.set(entity, "set using reflection");
f.setAccessible(false);
}
}
System.out.println(entity.getField());
Run Code Online (Sandbox Code Playgroud)
该程序打印"使用反射设置".但是,在数据库中,使用反射设置的值不会更新:
SELECT * FROM ENTITY WHERE ID = 1
ID FIELD
1 set directly
Run Code Online (Sandbox Code Playgroud)
这很奇怪.我可以发誓这曾经发挥作用 - 但现在却不行.难道你真的不能用反射来操纵实体吗?
如果重要的话,我正在使用EclipseLink 1.1.1.
我需要选择一个字段以几个不同前缀之一开头的行:
select * from table
where field like 'ab%'
or field like 'cd%'
or field like "ef%"
or...
Run Code Online (Sandbox Code Playgroud)
在Oracle或SQL Server中使用SQL执行此操作的最佳方法是什么?我正在寻找类似以下语句(不正确)的内容:
select * from table where field like in ('ab%', 'cd%', 'ef%', ...)
Run Code Online (Sandbox Code Playgroud)
要么
select * from table where field like in (select foo from bar)
Run Code Online (Sandbox Code Playgroud)
编辑:我想看看如何通过在一个SELECT语句中给出所有前缀,将所有前缀存储在帮助程序表中来完成此操作.
前缀的长度不固定.
我们在生产中使用MySQL,在Derby中使用单元测试.我们的pom.xml在测试之前复制了derby版本的persistence.xml,并在prepare-package阶段将其替换为MySQL版本:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>copy-test-persistence</id>
<phase>process-test-resources</phase>
<configuration>
<tasks>
<!--replace the "proper" persistence.xml with the "test" version-->
<copy
file="${project.build.testOutputDirectory}/META-INF/persistence.xml.test"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>restore-persistence</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<!--restore the "proper" persistence.xml-->
<copy
file="${project.build.outputDirectory}/META-INF/persistence.xml.production"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
问题是,如果我执行mvn jetty:run它将在启动jetty之前执行测试persistence.xml文件复制任务.我希望它使用部署版本运行.我怎样才能解决这个问题?
我们需要能够通知Delphi应用程序,以防MySQL中的某些表发生变化.
Delphi客户端位于防火墙后面的Internet中,在连接到我们需要实现的通知服务器之前,必须对它们进行身份验证.服务器可以使用例如Java,PHP或Python进行编程,并且必须支持数千个客户端.
通常,数据库中的一个更改只需要通知单个客户端,我不认为性能会成为瓶颈.当影响特定客户端的更改发生时,必须能够通知数千个客户端中的任何一个.
我一直在考虑一个解决方案:
我的问题:
有人成功地将EAR远程部署到JBoss 5.1.0.GA吗?我的pom.xml配置如下:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<type>remote</type>
<timeout>600000</timeout>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>username</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
<cargo.hostname>myserver</cargo.hostname>
<cargo.servlet.port>8888</cargo.servlet.port>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误消息:
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://myserver:8888/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=file:d%3A%5Cear%5Cmy-ear-1.0-SNAPSHOT.ear
Run Code Online (Sandbox Code Playgroud)