如何使用OpenJDK 7编译mavenized OSGi 4.3包?

我正在尝试使用OpenJDK7针对OSGi规范4.3编译我的OSGi包但我收到错误: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile (default-compile) on project example: Compilation failure [ERROR] /tmp/baka/example/src/main/java/org/example/Activator.java:[14,24] error: type ServiceReference does not take parameters 这是我的Activator.java: package org.example; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; public class Activator implements BundleActivator { @Override public void start(BundleContext bundleContext) throws Exception { ServiceReference ref = bundleContext.getServiceReference(Runnable.class); } @Override public void stop(BundleContext bundleContext) […]

Java – 在迭代时向列表添加元素

我想避免得到ConcurrentModificationException 。 我该怎么办?

如何使用Session Factory从Java Hibernate执行sql存储过程?

我无法使用会话工厂从java hibernate调用我的存储过程 我编写了一个sql过程,它接受5个参数并返回一个在MS SQL studio中正常工作的结果集 EXEC SlaGrid @appID=245,@fromYear=2012,@toYear=2013,@fromMon=1,@toMon=12 — sql EXEC SlaGrid @applID=:applID,@fromYear=:fromYear,@toYear=:toYear,@fromMon=:fromMon,@toMon=:toMon –hibernate 我正在设置上述查询的参数 String queryString = “EXEC SlaGrid @applID=:applID,@fromYear=:fromYear,@toYear=:toYear,@fromMon=:fromMon,@toMon=:toMon” Query query = sessionFactory.getCurrentSession().createSQLQuery(queryString); //set query parameters here query.list() — giving sql grammer exception

Firefox错误:使用Java启动Selenium 3.0.1驱动程序时“您的连接不安全”

我的Firefox版本是46.0.1,Selenium版本是3.0.1。 我收到错误: 您的连接不安全 执行以下代码时: @Test public void test() { ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffProfile = profile.getProfile(“newCretedProfile”); ffProfile.setAcceptUntrustedCertificates(true); ffProfile.setAssumeUntrustedCertificateIssuer(false); System.setProperty(“webdriver.gecko.driver”, “D:\\SELENUIUM\\Drivers\\geckodriver.exe”); FirefoxDriver driver = new FirefoxDriver(ffProfile); driver.get(“http://www.google.com”); driver.quit(); } 我创建了新的firefox配置文件,并按照此URL的步骤操作 然而,当我启动任何网站时,它不起作用并给我同样的错误。

是否有办法在maven尝试解决它们之前安装maven依赖项?

我必须从远程位置解压缩一些依赖项并在本地安装它们。 我成功地获取它们(使用antrun插件)并安装它们(使用安装插件) 但是,如果我将它们定义为依赖项( .. ),则maven首先尝试解析它们,然后,如果成功,则继续执行antrun并安装。 我还尝试了build-helper-plugin及其attach-artifact,但它没有做任何事情(它甚至没有将工件添加到最终的war文件中) 那么,如何在maven尝试解决依赖关系之前运行我的执行?

Java鼠标“手电筒”效果如何?

我正在编写一个简单的2D迷宫游戏,你可以通过很多房间。 我希望通过限制玩家的观点来使其变得有点挑战。 起初我想过将框架中的默认鼠标图标替换为半透明的PNG椭圆,但后来我意识到我需要阻止它周围的东西。 我能想到的唯一方法是将鼠标指针图标设置为比框架大的图像(因此当用户移动到角落时仍然是黑色时)填充它然后放置清晰褪色的椭圆在指针区域。 我想知道的是,这是可能的,我将如何做到这一点? 我正在学习java所以示例和oracle文档对我很有帮助。 提前致谢! 从这里看到这个链接 (加载需要一段时间)PS:我正在使用eclipse。

整数过大

嗨,我很难理解为什么这不起作用 if(Long.parseLong(morse) == 4545454545){ System.out.println(“2”); } 莫尔斯只是一串数字。 问题是它说Integer数字太大了:4545454545,但我确定Long可以比这长得多。

java.net.SocketException:软件导致连接中止:recv失败,java.net.SocketException:连接重置

我在Netbeans IDE中的Java,Hibernate,MySQL项目中遇到exception。 我已经做了一些挖掘尝试修复这个奇怪的Socketexception,但无济于事。 一些论坛解决方案建议为Hibernate实现c3p0连接池。 没有修复。 其他人建议禁用AV和防火墙(!!),因为这些可能会干扰套接字连接。 没有修复。 我用Hibernate标记了这个问题,因为我不确定hibernate是什么原因,但Hibernate调用(运行查询)会发生exception。 应用程序中的其他Hibernate代码工作正常。 Hibernate版本是3.2。 例外: NotifyUtil::java.net.SocketException: Software caused connection abort: recv failed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) at java.io.FilterInputStream.read(FilterInputStream.java:116) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2676) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) at java.io.BufferedReader.readLine(BufferedReader.java:362) at org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:299) 此exception可能发生一次或几次,之后不会发生此exception: NotifyUtil::java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:168) […]

如何禁用mongoDB java驱动日志记录?

我试图禁用mongo-java-driver-3.0.0日志输出。 在加载mongo驱动程序之前,我已尝试在应用程序的开头设置它们,但它没有帮助。 // Enable MongoDB logging in general System.setProperty(“DEBUG.MONGO”, “false”); // Enable DB operation tracing System.setProperty(“DB.TRACE”, “false”); 我得到这种日志: 11:01:15.406 [pool-1-thread-1] DEBUG org.mongodb.driver.protocol.query – Sending query of namespace susudev.Players on connection [connectionId{localValue:2, serverValue:28}] to server localhost:27017 11:01:15.406 [pool-1-thread-1] DEBUG org.mongodb.driver.protocol.query – Query completed 11:01:25.174 [cluster-ClusterId{value=’554dbecb1b554f11e86c3a69′, description=’null’}-localhost:27017] DEBUG org.mongodb.driver.cluster – Checking status of localhost:27017 11:01:25.177 [cluster-ClusterId{value=’554dbecb1b554f11e86c3a69′, description=’null’}-localhost:27017] […]

使用JFrame的setIconImages()方法的图标大小是多少?

有没有人知道哪些图标大小与jFrame的setIconImages()(PLURAL)方法一起使用,以便我的应用程序图标在所有平台和所有上下文中都能很好地显示(例如,窗口图标,任务栏图标,alt-tab图标等。 )? 我找到了一个使用16px-by-16px和32px-by-32px图像的示例,但是我需要更大吗? 为了测试,我还尝试将64px和128px版本添加到传递给setIconImages()的List中,但这些版本似乎没有在我的Windows 7机器上使用。 但是,我无法在其他机器上轻松测试,所以我想知道是否有人知道我应该包括哪些尺寸?