小编J.O*_*sen的帖子

Android谷歌地图 - keytool生成SHA1而不是MD5哈希

当我尝试使用Keytool"C:\ Program Files\Java\jdk1.7.0\bin"生成MD5密钥时,使用以下参数:

C:>"C:\ Program Files\Java\jdk1.7.0\bin\keytool.exe"-list -alias和roiddebugkey -keystore"C:\ Users\user1.android\debug.keystore"-storepass andro id -keypass android androiddebugkey,20.09.2011,PrivateKeyEntry,Huella Digital de Certificado(SHA1):ED:55:7E:68:28:7A:90:28:B1:2F:62:3A:B5:94:06:DD:C4 :6C:D6:20

当我试图提交这个"ED:55:7E:68:28:7A:90:28:B1:2F:62:3A:B5:94:06:DD:C4:6C:D6:20" http://code.google.com/android/maps-api-signup.html的关键- 它不起作用.如何使它工作?为什么我有SHA1而不是MD5?

android

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

如何在java swing中查看当前窗口大小?

例如,窗口的大小已更改(用户调整大小),如何获取当前窗口大小?

java swing

8
推荐指数
2
解决办法
5万
查看次数

无法检索PlatformTransactionManager以进行测试上下文的@Transactional测试

当尝试在事务之间测试Hibernate(版本4)EHCache的缓存功能时,它失败了:Failed to retrieve PlatformTransactionManager for @Transactional test for test context.

测试

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ApplicationConfig.class, CachingConfig.class }, loader = AnnotationConfigContextLoader.class)
@PersistenceContext
@Transactional
public class EHCacheTest extends AbstractTransactionalJUnit4SpringContextTests {
    @Autowired
    private SessionFactory sessionFactory;
@Test
    public void testTransactionCaching(){
        Session session = sessionFactory.getCurrentSession();
        System.out.println(session.get(CustomerEntity.class, 1));
        Query query = session.createQuery("from CustomerEntity where CustomerEntity.customerId<10").setCacheable(true).setCacheRegion("customer");
        @SuppressWarnings("unchecked")
        List<CustomerEntity> customerEntities = query.list();
        System.out.println(customerEntities);

        TestTransaction.flagForCommit();
        TestTransaction.end();

        TestTransaction.start();

        Session sessionNew =  sessionFactory.getCurrentSession();
        System.out.println(sessionNew.get(CustomerEntity.class, 1));
        Query anotherQuery = sessionNew.createQuery("from CustomerEntity where CustomerEntity.customerId<10");
        anotherQuery.setCacheable(true).setCacheRegion("customer");
        @SuppressWarnings("unchecked")
        List<CustomerEntity> customerListfromCache = anotherQuery.list(); …
Run Code Online (Sandbox Code Playgroud)

java junit spring hibernate transactions

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

在JFrame关闭时终止正在运行的线程

当用户关闭JFrame窗口时如何调用额外的操作?我必须停止现有的线程.

据我了解,setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);导致框架关闭,其线程停止.螺纹应该在关闭之后JFrame.EXIT_ON_CLOSE

客户:

static boolean TERMINATE = false;
public static void main(String[] args) {
// some threads created
 while(true) {

                if(TERMINATE){
                         // do before frame closed
                    break;
                         }
              }

}
    private static JPanel startGUI(){
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel gui = new JPanel();
             f.add( gui);
             f.setSize(500,500);
             f.setVisible(true);
             return gui;
        }
Run Code Online (Sandbox Code Playgroud)

我需要关闭线程正在使用的套接字.这样做的最佳做法是什么?

java swing multithreading jframe windowlistener

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

无法找到或加载主类org.junit.runner.JUnitCore

我将测试类打包到JAR中.我有junit-4.10.jaraJar.jar在同一个文件夹中.当我尝试执行时:

java -cp .:junit-4.10.jar org.junit.runner.JUnitCore TestOne

Error: Could not find or load main class org.junit.runner.JUnitCore
Run Code Online (Sandbox Code Playgroud)

如何使它工作?

当我输入: java aJar.jar:junit-4.10.jar org.junit.runner.JUnitCore TestOne

我正进入(状态

Error: Could not find or load main class aJar.jar:junit-4.10.jar
Run Code Online (Sandbox Code Playgroud)

java junit windows-7

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

休眠二级ehcache小姐

我正在尝试使用ehcache实现来获得二级hibernate缓存.

我确定这是我正在做的一些明显的noob错误,但我看不出它是什么!

为了测试我的缓存,我正在做以下事情:

创建一个对象并保存它.我在事务中得到了一次,在那里我可以看到我在没有数据库命中的情况下返回对象,这只是休眠的第一级缓存.

然后我提交事务并开始一个新会话.

这次,当我'得到'对象时,我可以在调试中看到来自ehcache的缓存未命中.因为我将它保存在上一个事务中,所以我原本期望该对象在缓存中?

这是我的代码:

  Session session = getSession();   
  session.beginTransaction();

  Test1 test1a = new Test1();
  test1a.setId(5);
  test1a.setName("Test 1");
  test1a.setValue(10);
  // Touch it
  session.save(test1a);

  // Now get it
  Test1 test1b = (Test1)session.get(Test1.class, 5);

  // Within a transaction, the session caches it - no db hit
  System.out.println("GOT object with value "+test1b.getValue());

  session.getTransaction().commit();

  System.out.println("Between sessions");

  session = getSession();
  session.beginTransaction();

  test1b = (Test1)session.get(Test1.class, 5);

  System.out.println("GOT object with value "+test1b.getValue());

  session.getTransaction().commit(); 
Run Code Online (Sandbox Code Playgroud)

这是我的hibernate.cfg.xml的相关部分

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
Run Code Online (Sandbox Code Playgroud)

还有我的ehcache.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.sf.net/ehcache.xsd"> 
    <cache name="com.play.hibernate1.Test1" …
Run Code Online (Sandbox Code Playgroud)

java hibernate ehcache

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

如何为IntelliJ IDEA安装apache commons库?

commons-lang3-3.1-bin.zipcommons.apache.org下载并用java 压缩到文件夹jdk/lib.我需要从这个库导入秒表.如何为IntelliJ IDEA做到这一点?

更新:为什么不智能只是将pom.xml添加到现有项目而不尝试删除它? 在此输入图像描述

解决这个问题:

http://commons.apache.org/ intelliJ>项目结构>依赖项> +>库>从commons.apache.org 下载lib的路径

PS.仍在寻找使用Maven解决这个问题的方法......

没有用Maven解决: 在此输入图像描述

无法运行项目.我可能不得不以某种方式配置它......

1

在此输入图像描述

2

在此输入图像描述

怎么解决?

在此输入图像描述

java intellij-idea

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

Spring MVC Web应用程序:找不到默认构造函数

项目ZIP:http://goo.gl/ddhLg5


无法执行Spring Web应用程序,从而出现HTTP Status 500错误.它还写出没有为DSLR找到默认构造函数,但实际上有一个默认构造函数.也许它与应用程序上下文或我的bean声明的方式有关?我的申请无法启动的原因是什么?

DSLR:

 package main.java.com.springapp.mvc.model;

    public class DSLR {

    public DSLR() {
    }
    public void init() {}

    private int dslrId;
    private String model;
    private int price;
    private String description;

    public int getDslrId() {
        return dslrId;
    }

    public void setDslrId(int dslrId) {
        this.dslrId = dslrId;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

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

如何通过在Hibernate中引入二级缓存来解决N + 1问题?

在Hibernate文档的性能部分中说明:

对N + 1选择问题采用完全不同的方法是使用二级缓存.

我不明白它是如何解决问题的.什么可能是现实世界的例子和解释?

java caching hibernate jpa second-level-cache

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

java.lang.IllegalStateException:Autowired annotation需要至少一个参数

无法自动装配和运行Spring Web应用程序.

错误:

java.lang.IllegalStateException: Autowired annotation requires at least one argument: public main.java.com.springapp.mvc.controller.DSLRServletController()
Run Code Online (Sandbox Code Playgroud)

DSLRServletController:

package main.java.com.springapp.mvc.controller;

import main.java.com.springapp.mvc.dao.DSLRDAO;
import main.java.com.springapp.mvc.model.DSLR;
import main.java.com.springapp.mvc.pckg.DSLRForm;
import main.java.com.springapp.mvc.pckg.DSLRValidaor;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;

@Controller
public class DSLRServletController   {
    static Logger logger = Logger.getLogger(DSLRServletController.class);


    private DSLR DSLR;
    private DSLRDAO dslrDAO;
    private DSLR dslr;



    @Autowired
    public DSLRServletController() {
        this.dslrDAO = new …
Run Code Online (Sandbox Code Playgroud)

java spring

5
推荐指数
2
解决办法
9446
查看次数