我尝试运行Android程序时出现以下错误.
请解释我到底adb是什么,以及如何重新启动它?
我收到以下错误
The connection to adb is down, and a severe error has occured.
You must restart adb and Eclipse.
Run Code Online (Sandbox Code Playgroud) /**
* Returns the empty map (immutable). This map is serializable.
*
* <p>This example illustrates the type-safe way to obtain an empty set:
* <pre>
* Map<String, Date> s = Collections.emptyMap();
* </pre>
* Implementation note: Implementations of this method need not
* create a separate <tt>Map</tt> object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* …Run Code Online (Sandbox Code Playgroud) 我正在使用JUnit 4,Maven 2和最新的Eclipse.问题很简单:我想在执行测试之前执行一些设置(连接到数据库).
我在许多不同的地方尝试过@BeforeClass,但Eclipse和Maven都忽略了这一点.有关完成此初始设置的任何帮助吗?
谢谢!
public abstract class BaseTestCase extends TestCase {
@BeforeClass
public static void doBeforeClass() throws Exception {
System.out.println("No good @BeforeClass");
// DO THE DATABASE SETUP
}
}
Run Code Online (Sandbox Code Playgroud)
现在扩展BaseTestCase的测试:
public class LoginActionTest extends BaseTestCase {
@Test
public void testNothing() {
System.out.println("TEST HERE");
assertEquals(true, true);
}
}
Run Code Online (Sandbox Code Playgroud)
Maven和Eclipse只是忽略了我的@BeforeClass ??? 在测试之前执行设置的任何其他方式?
最近我遇到了Reflection API,令我惊讶的是我们可以访问甚至更改私有变量.我尝试了以下代码
import java.lang.reflect.Field;
public class SomeClass{
private String name = "John";
}
public class Test{
public static void main(String args[]) throws Exception {
SomeClass myClass = new SomeClass();
Field fs = myClass.getClass().getDeclaredField("name");
fs.setAccessible(true);
System.out.println("Variable is " + fs.getName() + " and value is "
+ fs.get(myClass));
fs.set(myClass, "Sam");
System.out.println("Variable is " + fs.getName() + " and value is "
+ fs.get(myClass));
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了以下输出.
Variable is name and value is John
Variable is name and value is Sam
Run Code Online (Sandbox Code Playgroud)
我们说Java是一种面向对象的语言,它的主要特性是数据封装,继承,多态......等不是反射API改变了数据封装的目的吗?为什么我们必须使用Reflection …
当我们说
Class c = Integer.class;
System.out.println(c);
Run Code Online (Sandbox Code Playgroud)
它打印
class java.lang.Integer
这是有道理的,因为java.lang.Integer是一个阶级.所以我们可以有一个相应的Class对象.
但是,当我这样做
Class c1 = int.class;
System.out.println(c1);
Run Code Online (Sandbox Code Playgroud)
它打印int我觉得有点模棱两可,因为.class返回一个类型的对象Class而int不是一个类(但是一个原始类型).
当没有这样的class(primitiveType.class.getName())时,允许对原始类型进行.class操作的动机是什么?
如果你看到toString()类的方法Class
public String toString() {
return (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
+ getName();
}
Run Code Online (Sandbox Code Playgroud)
由于原始类型不是类或接口,因此只需打印名称(intfor int).那么为什么要允许创建Class一个不存在的类的对象呢?
我正在阅读Effective Java,并且遇到了这个例子.
class Elvis implements Serializable {
public static final Elvis inst = new Elvis();
private Elvis() {
System.out.println("In elvis constructor ");
}
public static Elvis getInstance() {
return inst;
}
}
Run Code Online (Sandbox Code Playgroud)
根据这本书,当我反序列化时,应该构造一个新的ELVIS对象,但是我看到在反序列化时没有调用构造函数?
这是我的代码序列化和反序列化.
FileOutputStream fos = new FileOutputStream("myserial1.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
Elvis e = Elvis.getInstance();
System.out.println(" e = "+e.getInstance());
oos.writeObject(e);
System.out.println("Serialization done.");
FileInputStream fis = new FileInputStream("myserial1.txt");
ObjectInputStream ois = new ObjectInputStream(fis);
Elvis el = (Elvis) ois.readObject();
System.out.println(" el = "+el.getInstance());
Run Code Online (Sandbox Code Playgroud)
我看到e和e1都引用相同的引用,构造函数只被调用一次.
我在这里误解了这个概念吗?
请帮忙.
我有一个需要身份验证才能访问它的任何页面的 web 应用程序。但是为了让我的 ELB 工作,我必须为 ELB 设置健康检查页面,以便 ELB 发现 django 应用程序。
此页面应返回 HTTP 200 且无需身份验证。我如何使用 django/nginx 世界设置它。
我希望Eclipse下载并安装Apache Tomcat服务器环境,但该选项对我来说是灰色的
知道可能缺少什么吗?
Eclipse details :
Eclipse Java EE IDE for Web Developers.
Version: Mars.2 Release(4.5.2)
Java 8
Run Code Online (Sandbox Code Playgroud) Studio无法自行下载appengine sdk.给予 -
错误:无法解析配置的所有依赖项':DeviceLocatorBackend:appengineSdk'.无法下载工件'appengine-java-sdk.zip(com.google.appengine:appengine-java-sdk:1.9.18)'无法下载资源' https://jcenter.bintray.com/com/google/appengine /appengine-java-sdk/1.9.18/appengine-java-sdk-1.9.18.zip '.Content-Length分隔邮件正文的过早结束(预期:172104706;收到:79691776
所以我禁用了下载部分并决定手动设置 -
build.gradle -
dependencies {
//appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
}
appengine {
//downloadSdk = true
appcfg {
oauth2 = true
}
}
Run Code Online (Sandbox Code Playgroud)
评论下载设置和手动创建的gradle.properties文件并添加
systemProp.appengine.sdk.root=/Users/athakur/Dropbox/personal/DeviceLocatorProject/SDK/appengine-java-sdk-1.9.42
Run Code Online (Sandbox Code Playgroud)
我还设置了环境变量 -
export APPENGINE_HOME=/Users/athakur/Dropbox/personal/DeviceLocatorProject/SDK/appengine-java-sdk-1.9.42
Run Code Online (Sandbox Code Playgroud)
它仍然给我以下错误 -
错误:任务':DeviceLocatorBackend:appengineEndpointsGetClientLibs'的执行失败.未设置App Engine SDK根目录.请确保设置环境变量'APPENGINE_HOME'系统属性'appengine.sdk.root'!
我在这里错过了什么?
我是春天的新手
这是代码:
pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shr</groupId>
<artifactId>app</artifactId>
<name>SpringDemoProject</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency> …Run Code Online (Sandbox Code Playgroud) java ×5
eclipse ×3
adb ×1
amazon-elb ×1
android ×1
class ×1
collections ×1
django ×1
gradle ×1
immutability ×1
java-ee ×1
junit ×1
macos ×1
map ×1
maven ×1
nginx ×1
primitive ×1
private ×1
reflection ×1
spring ×1
spring-mvc ×1
tomcat ×1