我在Netbeans中安装了Gradle-support插件,我可以很好地构建和运行该项目.当我尝试在调试模式下运行时,我得到以下输出:
Executing: gradle debug
:debug
Cannot execute debug because the property "mainClass" is not defined or empty.
BUILD SUCCESSFUL
Total time: 0.222 secs
Run Code Online (Sandbox Code Playgroud)
我正在使用:
Oracle Java 1.8
Gradle 1.12
Netbeans 8.0
Gradle-Support 1.3.0
LinuxMint 16
Run Code Online (Sandbox Code Playgroud)
为什么我不能运行我的调试器?
我在这里遵循开发指南:
https://developer.android.com/guide/components/activities/testing
并有一个测试类,如:
@RunWith(AndroidJUnit4::class)
class MyTestSuite {
@get:Rule var activityScenarioRule = activityScenarioRule<MyActivity>()
@Test fun testEvent() {
val scenario = activityScenarioRule.scenario
}
}
Run Code Online (Sandbox Code Playgroud)
该方法activityScenarioRule<T>()未定义。我需要什么依赖?另外,在阅读这些文档时确定要添加哪些依赖项的最佳方法是什么?
尝试编译用kotlin编写的单元测试时出现以下错误。
Task :app:compileDebugUnitTestKotlin FAILED ...Cannot inline bytecode built with JVM target 1.7 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
我尝试android在我的应用中为我的配置设置源兼容性build.gradle:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)
以及在root中配置所有kotlin编译任务build.gradle:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.8'
}
}
Run Code Online (Sandbox Code Playgroud) 由于某种原因,我在db.SaveChanges();指令中收到以下错误:
Cannot insert the value NULL into column 'UserId', table 'XXXXXXXXX_Dev.dbo.Portfolios'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Run Code Online (Sandbox Code Playgroud)
控制器代码:
[HttpPost]
[Authorize]
public ActionResult Create(Portfolio portfolio)
{
if (ModelState.IsValid)
{
portfolio.UserId = (Guid)Membership.GetUser().ProviderUserKey;
db.AddToPortfolios(portfolio);
db.SaveChanges();
}
return View("MyPortfolios");
}
Run Code Online (Sandbox Code Playgroud)
我已经通过调试器并确认正在填充UserID.
更新:
我试图改变db.AddToPortfolios(portfolio);到db.Portfolios.AddObject(portfolio);,但它仍然有同样的问题.
Portfolios是一个ObjectSet,我应该使用这个Attach()方法吗?
我在Stack Overflow上读过类似的问题,但是他们没有帮助.这是我的代码:
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Hello World')
pygame.mouse.set_visible(1)
done = False
clock = pygame.time.Clock()
while not done:
clock.tick(60)
keyState = pygame.key.get_pressed()
if keyState[pygame.K_ESCAPE]:
print('\nGame Shuting Down!')
done = True
Run Code Online (Sandbox Code Playgroud)
按下escape不会退出游戏或打印消息.这是一个错误吗?如果我打印keyState [pygame.K_ESCAPE]的值,它总是为零.
我不确定这是否是一个stackoverflow问题,因为它是一般的所以原谅我,如果是的话.
假设我有以下标记:
<div class="plugin"> ... </div>
<div class="plugin"> ... </div>
<div class="plugin"> ... </div>
Run Code Online (Sandbox Code Playgroud)
我不想运行一个jquery插件并将它传递给每个具有plugin该类的元素:
$(".plugin").myPlugin();
Run Code Online (Sandbox Code Playgroud)
插件代码看起来像这样:
;(function ( $, window, undefined ) {
var myPlugin = 'myPlugin',
document = window.document,
defaults = {
propertyName: "value"
};
// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = myPlugin;
this.init();
}
Plugin.prototype.init = function () {
};
// A really lightweight plugin wrapper …Run Code Online (Sandbox Code Playgroud) 我有一个项目需要运行本机库.我正在使用Gradle-Support Netbeans插件.
apply plugin: "java"
apply plugin: "application"
apply plugin: "eclipse"
sourceCompatibility = 1.7
mainClassName = "com.myPackage.MainClass"
if (!project.hasProperty('mainClass')) {
ext.mainClass = mainClassName
}
repositories {
mavenCentral()
maven {
url "http://teleal.org/m2"
}
}
dependencies {
compile group: "com.esotericsoftware.kryo", name: "kryo", version: "2.23.0"
compile group: "net.java.jinput", name: "jinput", version: "2.0.5"
compile group: "org.jcraft", name: "jorbis", version: "0.0.17"
compile group: "org.jdom", name: "jdom2", version: "2.0.5"
compile group: "org.lwjgl.lwjgl", name: "lwjgl", version: "2.9.0"
compile group: "org.lwjgl.lwjgl", name: "lwjgl_util", version: "2.9.0"
compile group: "org.teleal.cling", …Run Code Online (Sandbox Code Playgroud) 给定一个具有最终私有字段 _bar 的类:
class Foo() {
final Bar _bar;
Foo({Bar bar}) : _bar = bar {
//error: list cannot be used as setter, it is final
_bar = new Bar();
}
}
Run Code Online (Sandbox Code Playgroud)
尝试在参数列表中设置它会导致此错误
//error: default values of an object must be constant
Foo({Bar bar: new Bar()}) : _bar = bar ..
Run Code Online (Sandbox Code Playgroud)
我想保留可选参数,以便我可以在单元测试期间注入模拟。最好的方法是什么?
我正在编写一个浏览器扩展,需要将处理程序附加到所有页面上的keyup和keydown事件.我可以使用以下内容脚本代码很好地工作.
document.addEventListener("keydown",keyDown, true);
document.addEventListener("keyup", keyUp, true);
Run Code Online (Sandbox Code Playgroud)
我不能让这个在Gmail中运行.具体来说,在编写新电子邮件的正文时,我无法使其工作.它将适用于我测试过的其他任何地方.我认为问题是因为Gmail正在调用stopPropagation所有键盘事件,但很难调试其最小化代码.我认为将第3个参数设置为true会导致在CAPTURE_PHASE此期间捕获事件,但这不起作用.
如何使用Google Chrome内容脚本在Gmail中编写新主体时捕获keyup和捕获keydown事件?
编辑:
通过添加"all_frames": true,到我的清单,我确保将我的内容脚本注入到DOM的所有iframe中.我甚至尝试使用以下代码:
document.addEventListener("DOMNodeInserted", function (event) {
if(event.type === "DOMNodeInserted") {
if(event.srcElement.nodeName === "IFRAME") {
console.log(event.srcElement.nodeName + " iframe detected");
event.srcElement.addEventListener("keydown", function(kevent) {
document.dispatchEvent(kevent);
}, true);
event.srcElement.addEventListener("keyup", function(kevent) {
document.dispatchEvent(kevent);
}, true);
}
}
},true);
Run Code Online (Sandbox Code Playgroud)
这仍然无法解决Gmail的问题.
我是大多数客户端编程形式的新手.所以本周末我正试着练习一下.
我创建了一个简单的ASP.net MVC 3站点,并成功获得Ajax以部分视图更新div.现在我正在尝试使用Jquery下滑动画来显示新内容.
以下是我在布局页面中包含的脚本:
我添加了Jquery UI
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
这是我写的视图代码:
<div id = "Result"><p>this is an old statement</p></div>
<p>
@Ajax.ActionLink("Ajax Request","AjaxRequest", new AjaxOptions{UpdateTargetId = "Result", OnSuccess = "animate" })
<script>
function animate() {
$('#Result').slideDown('slow')
}
</script>
Run Code Online (Sandbox Code Playgroud)
和动作方法:
public ActionResult AjaxRequest()
{
AjaxStatement s = new AjaxStatement();
return PartialView("_Result", s);
}
Run Code Online (Sandbox Code Playgroud)
最后局部视图:
@model AjaxStuff.Models.AjaxStatement
<p>@Model.Statement</p>
<p>@Model.Statement</p>
<p>@Model.Statement</p>
<p>@Model.Statement</p>
Run Code Online (Sandbox Code Playgroud)
Ajax请求工作正常但我希望Jquery在触发OnSuccess后为部分视图设置动画.它应该向下滑动并显示所有四行文本.
我试图从文本文件中读取并标记输入.我收到了一个分段错误,直到我意识到我忘了关闭我的ifstream.我添加了close调用,现在它无限循环.我现在只是想学习如何使用strtok,这就是为什么代码看起来并不完整.
void loadInstructions(char* fileName)
{
ifstream input;
input.open(fileName);
while(!input.eof());
{
string line;
getline (input,line);
char * lineChar = &line[0];
//instruction cmd; //This will be used later to store instructions from the parse
char * token;
token = strtok (lineChar," ");
// just trying to get the line number for now
int lineNumber = atoi(token);
cout << lineNumber << "\n";
}
input.close();
}
输入文件:(一行)
5 +8 0 0 25
这是我的转换函数调用:
<p><%# MyFunctions.getDocumentCategory(Eval("DocumentID"))%></p>
Run Code Online (Sandbox Code Playgroud)
这是功能:
public static string getDocumentCategory(int documentID)
{
string category;
StringBuilder sb = new StringBuilder();
// Get document categories
var ds = CategoryInfoProvider.GetDocumentCategories(documentID, "CategoryEnabled = 1", null);
// Check whether exists at least one category
if (!DataHelper.DataSourceIsEmpty(ds))
{
// Loop thru all categories
foreach (DataRow dr in ds.Tables[0].Rows)
{
sb.Append(Convert.ToString(dr["CategoryDisplayName"]) + ",");
}
}
string content = sb.ToString();
category = content.Split(',')[0];
return category;
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
MyFunctions.getDocumentCategory(int) has some invalid arguments.
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一种替代形式的函数,它接受字符串而不是整数但它会抛出相同的错误.我已经验证了Eval("DocumentID")单独放置时的工作原理.有任何想法吗?