我正在尝试创建NDK应用程序,但是我收到此错误:
java.lang.UnsatisfiedLinkError: Native method not found: com.example.hellondk.jni.HelloNDK.hello:()I
Run Code Online (Sandbox Code Playgroud)
我不明白,因为C++函数的名称与Java包名和类相同
HelloNDK.cpp
#include <jni.h>
JNIEXPORT jint JNICALL Java_com_example_hellondk_jni_HelloNDK_hello(JNIEnv* env, jobject o){
return (jint) 2;
}
Run Code Online (Sandbox Code Playgroud)
HelloNDK.java
package com.example.hellondk.jni;
public class HelloNDK {
public native int hello();
static {
System.loadLibrary("HelloNDK");
}
}
Run Code Online (Sandbox Code Playgroud)
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := HelloNDK
LOCAL_SRC_FILES := HelloNDK.cpp
include $(BUILD_SHARED_LIBRARY)
Run Code Online (Sandbox Code Playgroud) 我正在阅读一个javscript dojo库,我看到许多我无法理解的复杂函数.例如:
_refreshUI: function () {
this._hasUI && (g.empty(this.flowContainer), f.forEach(this.basemaps, function (a, b) { a.id || (a.id = "basemap_" + b); this.flowContainer.appendChild(this._buildNodeLayout(a))
}, this), g.create("br", { style: { clear: "both" } }, this.flowContainer), this._markSelected(this._selectedBasemap))
Run Code Online (Sandbox Code Playgroud)
这个函数写在一行上.它包含用逗号分隔的函数.所以我看不懂.
我不问上面的功能是做什么的.
这是什么意思?:
this._hasUI && (firstFunction, secondFunction, ...)
Run Code Online (Sandbox Code Playgroud)
它有什么作用?或者我怎么写清楚?
我已经创建了一个按钮,允许我平台的用户提交一个帖子,或者如果再次按下该按钮则删除之前的投票.
问题是当用户第二次点击按钮时,在投票后没有任何反应.
这是管理按钮行为的代码:
if($(".timeline-action-plus").hasClass("btn-success")) {
$(".timeline-action-plus").click(function(){
rating.removeVote($(this).data("entry-id"), $(this).data("token"));
});
} else {
$(".timeline-action-plus").click(function(){
rating.votePlus($(this).data("entry-id"), $(this).data("token"));
});
}
Run Code Online (Sandbox Code Playgroud)
该removeVote和votePlus功能还需要修改按钮的方面的护理:
function votePlus(id,token){
$.post(
"http://localhost/user/vote",
{
rating : '1',
entryID : id,
_token : token
},
function(result) {
if(result === "OK"){
$(".timeline-action-plus[data-entry-id=" + id + "]").removeClass("btn-default");
$(".timeline-action-plus[data-entry-id=" + id + "]").addClass("btn-success");
}
}
);
}
function removeVote(id, token) {
$.post(
"http://localhost/user/removeVote",
{
entryID : id,
_token : token
},
function(result) {
if(result === "OK") {
$(".timeline-action-plus[data-entry-id=" + id + …Run Code Online (Sandbox Code Playgroud) 我试着使用正则表达式替换方法来替换xxx="yyy"给定字符串中的文本模式.
我的模式是: /^[a-zA-Z0-9.;:|_-]+="[a-zA-Z0-9.;:_-]+\"/
码:
var userinput = '<div id="c16430" style="color:red;" class="css-btn">';
var pattern = /^[a-zA-Z0-9.;:|_-]+="[a-zA-Z0-9.;:_-]+\"/;
userinput = userinput.replace( pattern, "Replaced..." );
Run Code Online (Sandbox Code Playgroud)
但它没有用...... jsfiddle.怎么了?
提前致谢..
我正在使用@Configuration在我的JUnit Test中注释的类中定义的Spring配置的JUnit测试.测试看起来像这样:
@ContextConfiguration(classes = MyConfiguration.class})
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class SomeIntegrationTest {
@Autowired
private MyConfiguration myConfiguration;
@Test
public void someTest() throws Exception {
myConfiguration.myBean();
}
}
Run Code Online (Sandbox Code Playgroud)
在MyConfiguration,我想使用Spring范围SimpleThreadScope:
@Configuration
public class MyConfiguration {
@Bean
@Scope("thread")
public MyBean myBean() {
return new MyBean();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行测试时,范围没有注册.我明白了
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: java.lang.IllegalStateException: No Scope registered for scope 'thread'
Run Code Online (Sandbox Code Playgroud)
我知道如何以编程方式注册自定义作用域:
context.getBeanFactory().registerScope("thread", new SimpleThreadScope());
我想避免使用XML Spring配置.
有什么办法,我怎样才能在单元测试中注册自定义范围?
我的Maven项目给了我report.plugins.plugin.version这样的警告:
[WARNING] Some problems were encountered while building the effective model for com.example:test:jar:1.0-SNAPSHOT
[WARNING] 'reporting.plugins.plugin.version' for org.jacoco:jacoco-maven-plugin is missing. @ line 10, column 21
Run Code Online (Sandbox Code Playgroud)
我知道Maven 3 对插件版本更严格,必须指定插件版本.我在pluginManagement中指定了该版本:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
</plugin>
</plugins>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)
当我使用插件时,这工作正常,没有警告build/plugins:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用reporting/plugins:
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
Run Code Online (Sandbox Code Playgroud)
我的问题是:指定的版本范围是否build/plugingManagement仅限于<build>标签内?我可以修复警告而不在两个地方复制插件版本吗?
以下是生成警告的完整示例:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging> …Run Code Online (Sandbox Code Playgroud)