我正在尝试解决gcm超时问题,关于这个主题有很多线程,这里有一个供参考.
建议的解决方法是以比tcp超时短的间隔广播一对意图.
我的实现是创建一个扩展CountDownTimer类的类,并在现有服务中保存该类的实例.这个派生类在完成后重新启动并且服务被标记为STICKY_START,所以一旦启动,我认为它应该每4分钟继续广播意图,但由于某种原因存在间隙,当计数器没有广播时意图和我仍然与GCM服务器失去联系.
两个相关的课程如下.任何人都可以解释并提供一个解决方案,为什么这个策略不起作用?
我创建了一个扩展CounDownTimer的类,它应该每4分钟广播一次意图.
public class GcmKeepAlive extends CountDownTimer {
protected CountDownTimer timer;
protected Context mContext;
protected Intent gTalkHeartBeatIntent;
protected Intent mcsHeartBeatIntent;
public GcmKeepAlive(Context context) {
super(4*60* 1000,4*60*1000);
mContext = context;
gTalkHeartBeatIntent = new Intent("com.google.android.intent.action.GTALK_HEARTBEAT");
mcsHeartBeatIntent = new Intent("com.google.android.intent.action.MCS_HEARTBEAT");
System.out.println("stariing heartbeat countdown timer");
this.start();
}
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
System.out.println("sending heart beat to keep gcm alive");
mContext.sendBroadcast(gTalkHeartBeatIntent);
mContext.sendBroadcast(mcsHeartBeatIntent);
this.start();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序中的服务,它包含GcmKeepAlive类的实例
import android.app.Service; import android.content.Intent; import android.os.IBinder;
public …Run Code Online (Sandbox Code Playgroud) 我在使用 IntelliJ IDEA 时尝试应用 TDD 原则,但遇到了问题,我不知道是否有我不知道的功能或插件可以帮助我。
我刚刚发现您可以使用CTRL+ SHIFT+轻松导航到编辑器中与当前类相对应的测试类T。如果测试类不存在,它会要求您创建它。
在相反的情况下,当我创建一个没有相应测试主题的测试类并且我按上一个快捷方式时,它只是告诉我No test subjects found。

有没有办法在测试主题类不存在时快速创建它?
我有两个实体.Employee实体
@interface Employee : NSManagedObject
@property (nonatomic, retain) NSString * dept;
@property (nonatomic, retain) NSString * email;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) Department *deptEmp;
@end
Run Code Online (Sandbox Code Playgroud)
和Department实体
@interface Department : NSManagedObject
@property (nonatomic, retain) NSString * location;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) Employee *deptEmp1;
Run Code Online (Sandbox Code Playgroud)
我试图用以下谓词从两者获取信息
NSMutableString *queryString = [NSMutableString stringWithFormat:@"(name = 'Apple') AND (deptEmp1.location like 'Cupertino')"];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:self.managedObjectContext];
Run Code Online (Sandbox Code Playgroud)
并且获取请求是
NSFetchRequest *request = [[NSFetchRequest alloc] init]; …Run Code Online (Sandbox Code Playgroud) 在以下情况下是否可以进行 HTTP 响应拆分:
String requestFilename = request.getParameter("name");
response.addHeader("content-disposition", "attachment; filename=" + requestFilename);
Run Code Online (Sandbox Code Playgroud)
我直接将未经处理的请求参数附加到响应标头。
我的问题是,通过使用 CRLF 字符,我们可以将自己的标头插入响应中。
到目前为止,我已经尝试过\r\n,%0D%0A但它们不起作用。
是response.addHeader()不受此类攻击?
有人可以向我解释如何执行这种攻击吗?
是否可以在intellij的远程服务器上部署/运行(用于测试目的)独立的Java应用程序?我不是要连接到已经在运行的JVM,而是要从intellij在远程主机上启动新的JVM,就像它在本地计算机上运行一样?
我跟着讲座,讲师正在使用Eclipse,但我正在使用IntelliJ IDEA Community Edition 15.0.6,而名为rationals.scala的Scala工作表上的代码如下
object rationals{
val x = new Rational(1,2)
x.numer
x.denom
}
//noinspection ScalaPackageName
class Rational(x: Int, y: Int) {
def numer = x
def denom = y
}
Run Code Online (Sandbox Code Playgroud)
Scala工作表工作表将不会计算,并且存在与读取的类定义关联的警告(而不是错误)
包名称与目录结构不对应,这可能会导致解析此文件中的类时出现问题
此外,这是奇怪的,但可能很重要,IDEA标志着numer和denom作为拼写错误.
任何指导?谢谢
当我通过右键单击"Debug"在IntelliJ中运行我的sbt项目时,我收到此错误消息.
/home/johnreed/Applications/jdk1.8.0_73/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:34395,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /home/johnreed/Applications/jdk1.8.0_73/jre/lib/charsets.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/deploy.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/cldrdata.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/dnsns.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/jaccess.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/jfxrt.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/localedata.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/nashorn.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/sunec.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/sunjce_provider.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/sunpkcs11.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/ext/zipfs.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/javaws.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/jce.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/jfr.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/jfxswt.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/jsse.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/management-agent.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/plugin.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/resources.jar:/home/johnreed/Applications/jdk1.8.0_73/jre/lib/rt.jar:/home/johnreed/sbtProjects/UnderstandingScala/target/scala-2.11/classes:/home/johnreed/.ivy2/cache/com.chuusai/shapeless_2.11/bundles/shapeless_2.11-2.3.1.jar:/home/johnreed/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.8.jar:/home/johnreed/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-2.0.1.jar:/home/johnreed/.ivy2/cache/com.google.guava/guava/bundles/guava-16.0.1.jar:/home/johnreed/.ivy2/cache/com.twitter/jsr166e/jars/jsr166e-1.0.0.jar:/home/johnreed/.ivy2/cache/com.twitter/util-collection_2.11/jars/util-collection_2.11-6.34.0.jar:/home/johnreed/.ivy2/cache/com.twitter/util-core_2.11/jars/util-core_2.11-6.34.0.jar:/home/johnreed/.ivy2/cache/com.twitter/util-function_2.11/jars/util-function_2.11-6.34.0.jar:/home/johnreed/.ivy2/cache/commons-collections/commons-collections/jars/commons-collections-3.2.2.jar:/home/johnreed/.ivy2/cache/javax.inject/javax.inject/jars/javax.inject-1.jar:/home/johnreed/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11/bundles/scala-parser-combinators_2.11-1.0.4.jar:/home/johnreed/.ivy2/cache/org.typelevel/macro-compat_2.11/jars/macro-compat_2.11-1.1.1.jar:/home/johnreed/.ivy2/cache/scala.trace/scala-trace-debug_2.11/jars/scala-trace-debug_2.11-2.2.14.jar:/home/johnreed/Applications/idea-IC-145.258.11/lib/idea_rt.jar pkg.Main
Connected to the target VM, address: '127.0.0.1:34395', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:34395', transport: 'socket'
Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/api/TypeCreator
at pkg.Main.main(Main.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.api.TypeCreator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我从IntelliJ运行时只收到此错误.当我从SBT运行它时sbt run,它工作正常.sbt compile工作文件也是.我如何解决这个问题,以便我的项目作为应用程序运行?
*解决方案*
手动添加scala-reflect-2.11.8.jar
reflection scala intellij-idea classnotfoundexception intellij-scala
环境:jdk1.7
javax.servlet-api-3.0.1.jar 这个测试需要.
重现步骤:
javac Test1.java -cp javax.servlet-api-3.0.1.jar 使用javax.servlet-api-3.0.1.jar构建Test1.java
javac Test2.java -cp javax.servlet-api-3.0.1.jar 使用javax.servlet-api-3.0.1.jar构建Test2.java
javac Test3.java 构建Test3.java
java -classpath .:javax.servlet-api-3.0.1.jar Test3运行具有依赖性的Test3.以下是输出.这没关系.
hello world1
hello world2
但是当此命令java Test3运行时,抛出异常.这篇文章结尾的结果.奇怪的是,"hello world1"可以打印出来,但不会打印出"hello world2",而是抛出异常.
Test1.java
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
public class Test1 {
public void getRequest(HttpServletResponse resp) throws IOException {
OutputStream os = resp.getOutputStream();
resp.getOutputStream().close();
}
public void hello(String world) {
System.out.println("hello " + world);
}
}
Run Code Online (Sandbox Code Playgroud)
Test2.java
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
public class Test2 {
public void …Run Code Online (Sandbox Code Playgroud) 我为 IntelliJ IDEA 创建了一个插件,我希望它可以在 Android Studio 和其他基于 IDEA 的产品上运行。
我使用gradle-intellij-plugin 并有这样的设置:
构建.gradle
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id "org.jetbrains.intellij" version "0.2.17"
id "org.jetbrains.kotlin.jvm" version "1.2.10"
}
group pluginGroup
version pluginVersion
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'kotlin'
intellij {
version 'IC-2017.3'
plugins 'git4idea'
pluginName "plugin name"
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
//...
testCompile group: 'junit', name: 'junit', version: '4.12'
} …Run Code Online (Sandbox Code Playgroud) plugins intellij-idea intellij-plugin gradle android-studio-3.0
我有以下Kotlin枚举类:
enum class DurationModifier {
GreaterThan {
override val displayName = "?"
},
LessThan {
override val displayName = "?"
};
abstract val displayName: String
}
Run Code Online (Sandbox Code Playgroud)
很长时间以来,它一直是我项目的一部分,并且可以很好地进行编译。使用IntelliJ或Android Studio可以很好地进行编译,但是当我从命令行(./gradlew assembleDebug)手动运行gradle build时,我得到了:
e: {projectDir}/build/tmp/kapt3/stubs/{package}/search/DurationModifier.java:17: error: invalid method declaration; return type required
DurationModifier() {
^
Run Code Online (Sandbox Code Playgroud)
我已经彻底清理了所有我能想到的东西(构建目录,gradle缓存等)。
我最近做了很多更改,但是由于IDE一切正常,所以我不知道是什么原因引起的。怎么了 为什么这在IDE中有效但在命令行中无效?