小编Jul*_*egg的帖子

复制到没有Flash的剪贴板

我找到了许多复制到剪贴板的解决方案,但它们都可以使用闪存或网站方面.我正在寻找方法复制到剪贴板自动,没有闪存和用户方面,它是用户脚本,当然是跨浏览器.

javascript clipboard jquery

90
推荐指数
4
解决办法
8万
查看次数

子域的HTML5 localStorage大小限制

HTML5的localStorage数据库通常是大小限制的 - 标准大小为每个域5或10 MB.子域可以规避这些限制(例如example.com,hack1.example.com和hack2.example.com都有自己的5 MB数据库)?标准中是否有任何内容指定父域是否可以访问其子项的数据库?我找不到任何东西,我可以看到这样做的论据,但似乎必须有一些标准模型.

subdomain html5 limit local-storage

76
推荐指数
4
解决办法
8万
查看次数

java.lang.IllegalAccessError:试图访问方法

我得到一个例外,我找不到它的原因.

我得到的例外是:

java.lang.IllegalAccessError:试图访问方法Connected.getData(Ljava/lang/String;)Ljava/sql/ResultSet; 来自B班

该方法是公开的.

public class B
{
  public void myMethod()
  {
   Connected conn = new Connected();  // create a connected class in order to connect to The DB 
   ResultSet rs = null;  // create a result set to get the query result
   rs = conn.getData(sql); // do sql query
  }
}

public class Connected 
{
 public ResultSet getData(String sql) 
{
  ResultSet rs = null;
  try 
  {
     prepareConnection();
     stmt = conn.createStatement();
     stmt.execute(sql);
     rs = stmt.getResultSet();
  }
  catch (SQLException E) …
Run Code Online (Sandbox Code Playgroud)

java exception

69
推荐指数
2
解决办法
15万
查看次数

osx maven运行测试异常:从线程"main"中的UncaughtExceptionHandler抛出java.lang.OutOfMemoryError

我一直在尝试在mac上运行一个在linux下工作的maven项目.当mvn clean install 它调用 它运行一部分测试,然后我收到以下错误:

线程"main"中的异常异常:从线程"main"中的UncaughtExceptionHandler抛出java.lang.OutOfMemoryError

我已经看到许多关于Perm gen error的问题已经通过添加MAVEN_OPTS到环境变量来修复.现在我的系统上有以下环境变量:

MAVEN_OPTS =" - Xmx4096m -XX:MaxPermSize = 4096m"

通话时mvn help:system我可以看到配置中显示的这些选项.

该项目使用Robolectric进行测试,并且(在大多数情况下但并非总是如此)在抛出异常之前打印以下行:

[DEBUG]***********************GC'ed SdkEnvironment重复使用!

[ERROR]无法在org.robolectric.bytecode.AsmInstrumentingClassLoader@300abe53中加载org.robolectric.internal.ParallelUniverse

在活动监视器中,我可以看到一个java进程在我开始测试时生效.在抛出异常之前,它的内存使用量达到1.4~1.5GB.

我还应该做些什么才能让它发挥作用.谢谢你的帮助!

将内存选项添加到确定的fire插件后编辑:

           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.16</version>
               <configuration>
                   <argLine>-Xmx2048m -XX:MaxPermSize=2048m</argLine>
               </configuration>
           </plugin>
Run Code Online (Sandbox Code Playgroud)

并且运行mvn clean install -e -X我得到了以下堆栈跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project android: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] java.lang.OutOfMemoryError: PermGen space
[ERROR] at java.lang.ClassLoader.defineClass1(Native Method) …
Run Code Online (Sandbox Code Playgroud)

java macos android maven robolectric

11
推荐指数
1
解决办法
2万
查看次数

Wildfly 9 - 如何排除杰克逊

我正在遇到地图中带有空值的杰克逊序列化问题.显然,这是Wildfly 9使用的Jackson版本中的已知错误(https://issues.jboss.org/browse/WFLY-4906).我想使用当前版本的杰克逊; 但是,我在排除Wildfly使用的版本时遇到了麻烦.我尝试排除模块,jboss-deployment-structure.xml但排除不起作用.

JBoss的部署,structure.xml

知道我怎么能让这个工作吗?

jackson wildfly-9

7
推荐指数
2
解决办法
5627
查看次数

如何构建 Spring Boot Atomikos 测试配置?

如何创建适当的测试环境,以便能够在同一应用程序中使用数据库层测试和带有模拟的 REST 端点测试?

我有一个带有两个数据源的 Spring Boot 应用程序。用于管理 Atomikos 使用的交易。这个配置工作正常。

现在我需要创建测试。我构建了一个测试配置,每个测试都工作正常,但当我运行所有测试时它都会失败。在我看来(参见堆栈跟踪),问题是如果实例化很少的 Atomikos beans,Atomikos 就无法工作。

我尝试了两种解决方案来使 Atomikos beans 仅实例化一次:

  1. 创建一个用于所有测试的测试配置(因为 Spring 缓存测试上下文)。但这不起作用。我认为这是因为 @Controller 中的 Mock beans 破坏了重用 Spring 测试上下文的能力。我在测试中使用的持久性映射器组件在一个测试中被模拟,同时在其他测试中使用真实实例。所以我看到每个测试类都在它自己的测试上下文中运行。

  2. 在数据库 @Configuration 类上使用 @Lazy 注释。我认为这将确保 bean 仅在第一次调用时才会被实例化,并将在以后的调用中重用。但这也行不通。

这是我用来说明问题的示例项目链接。该存储库包括 MySQL 数据库转储: https: //github.com/pavelmorozov/AtomikosConfig

在这篇文章中,我将仅展示两个数据库模型、映射器和配置类中的一个,因为它们对于第二个数据库几乎相同。

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at …
Run Code Online (Sandbox Code Playgroud)

java testing spring atomikos spring-boot

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

StandardOpenOption.SPARSE的用途是什么?

Java 7 定义了该选项,但我仍然无法理解它的用处。

public static void main(final String... args)
    throws IOException
{
    final long offset = 1L << 31;
    final RandomAccessFile f = new RandomAccessFile("/tmp/foo", "rw");
    f.seek(offset);
    f.writeInt(2);
    f.close();
}
Run Code Online (Sandbox Code Playgroud)

当我查询文件“ shell wise”时,我得到了预期的结果:

$ cd /tmp
$ stat --format %s foo
2147483652
$ du --block-size=1 foo
4096    foo
Run Code Online (Sandbox Code Playgroud)

也就是说,inode真实地声明该文件的大小接近2 GB,但是由于基础fs的块大小为4k,因此其磁盘使用情况实际上是一个块。好。

但是我不需要Java 7 StandardOpenOption.SPARSE。实际上,如果我使用Java 7 JVM运行此完全相同的代码,则结果不会改变。

现在,转到一些仅Java 7的代码:

public static void main(final String... args)
    throws IOException
{
    final ByteBuffer buf = ByteBuffer.allocate(4).putInt(2);
    buf.rewind();

    final OpenOption[] options = {
        StandardOpenOption.WRITE, …
Run Code Online (Sandbox Code Playgroud)

java filesystems file-io java-7

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