我有下面的类用脚本编写的类.当我编译它时,它错误地说
"src\main\MqttClientWrapper.ts(24,2): error TS1068: Unexpected token. A construct
or, method, accessor, or property was expected.".
以下是我的代码.
var mqtt :any = require('mqtt');
export interface IWillMessage {
topic: string;
payload: string;
qos: number;
retain: string;
}
export interface IMessageReceivedCallBack {
onMessageReceived(message : string);
}
export interface IMqttOptions {
clientId: string;
keepAlive: number;
clean: string;
reconnectPeriod: string;
will: IWillMessage;
}
export default class MqttClientWrapper {
client : any;
constructor(url: string, mqttOptions : IMqttOptions, messageReceivedCallBack : IMessageReceivedCallBack) {
client = mqtt.connect(url, mqttOptions);
client.on('message',function(topic …Run Code Online (Sandbox Code Playgroud) 我有一个名为processOutbox的方法.我希望它是线程安全的.当一个线程在它时,我不希望另一个线程调用此方法.我已经按照以下方式实现了它.我做得对吗?我的实施有漏洞吗?如果有,请告知我如何解决它.
this.start();
outboxLock.lock();
timer = new Timer();
try{
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
processOutbox();
}
}, 0, period);
} finally{
outboxLock.unlock();
}
Run Code Online (Sandbox Code Playgroud) 我正在使用logback登录我的应用程序,并且在运行该应用程序时,我不断收到以下警告。当我运行单元测试时,它会在每堂课上打印出来!
SLF4J: The following set of substitute loggers may have been accessed
SLF4J: during the initialization phase. Logging calls during this
SLF4J: phase were not honored. However, subsequent logging calls to these
SLF4J: loggers will work as normally expected.
SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
SLF4J: com.kohls.kube.service.sdk.logging.CustomAppender
SLF4J: com.kohls.kube.service.sdk.logging.appender.mqtt.messaging.ClientMqttImpl
SLF4J: com.kohls.service.sdk.messaging.TCPMessager
SLF4J: com.kohls.service.sdk.logging.appender.mqtt.MQTTAppender
SLF4J: com.kohls.service.sdk.messaging.EdgeNodeMessager
SLF4J: com.kohls.service.sdk.messaging.SubscriptionTask
Run Code Online (Sandbox Code Playgroud)
我已经配置了logback,以在某个位置查找配置文件,下面是日志工厂类的外观。
public class LoggerFactory {
static {
System.setProperty("logback.configurationFile", System.getProperty("user.dir") + "\\" + "logbackConfig.xml");
}
private LoggerFactory() {
}
public static Logger getLogger(Class className) {
return …Run Code Online (Sandbox Code Playgroud) 我有一个Spring Boot应用程序,当通过intellij运行时可以正常工作。但是,当我从罐子中运行它时,出现以下异常。
2017-02-13 05:18:28.596 WARN 8581 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-02-13 05:18:28.606 ERROR 8581 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.6.RELEASE.jar!/:4.3.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE] …Run Code Online (Sandbox Code Playgroud) 我试图在Team City中运行我的Jest单元测试,但最终总是得到如下所示的提示。
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.
Run Code Online (Sandbox Code Playgroud)
我尝试运行yarn test a …
我有以下代码,我试图转换为Java.
WORD ComputeCRC16(BYTE *data, DWORD data_length)
{
BYTE *ptr;
BYTEWORD retval;
/* Initialize the CRC */
retval.w = 0xFFFF;
/* Iterate through the data */
for (ptr=data; ptr<data+data_length; ptr++)
{
// retval.w = IterateCRC16(ptr, retval);
retval.w = retval.b.hi ^ (ccittrev_tbl[retval.b.lo ^ *ptr]);
}
/* Finalize the CRC */
retval.w = ~retval.w;
/* Done. */
return retval.w;
}
Run Code Online (Sandbox Code Playgroud)
下面的内容是什么意思?
retval.w = retval.b.hi ^ (ccittrev_tbl[retval.b.lo ^ *ptr]);
Run Code Online (Sandbox Code Playgroud)
如果我转换为Java,retval应该是一个int吗?如果那么它怎么会有一个名为"w"的成员呢?请告诉我如何将上面的代码转换为Java?
我正在编辑问题,发布我错过的这部分内容.
typedef union
{
WORD w;
struct
{
BYTE lo,
hi;
} b;
} …Run Code Online (Sandbox Code Playgroud) 通常 EXE 版本在 Bundle.wxs 文件中设置。是否可以在编写安装程序后端引擎逻辑的 Bootstrapper 应用程序项目中获取此版本?我使用 WPF 创建了自定义 UI。我需要在用户界面中显示版本。我怎样才能做到这一点?请指教。下面是我的 Bootstrapper 应用程序代码。
public class MainViewModel : ViewModelBase
{
private MINAClient minaClient;
//constructor
public MainViewModel(BootstrapperApplication bootstrapper)
{
this.IsThinking = false;
this.Bootstrapper = bootstrapper;
this.Bootstrapper.ApplyComplete += this.OnApplyComplete;
this.Bootstrapper.DetectPackageComplete += this.OnDetectPackageComplete;
this.Bootstrapper.PlanComplete += this.OnPlanComplete;
this.Bootstrapper.DetectComplete += this.DetectComplete;
this.Bootstrapper.CacheAcquireProgress += (sender, args) =>
{
this.cacheProgress = args.OverallPercentage;
this.Progress = (this.cacheProgress + this.executeProgress) / 2;
};
this.Bootstrapper.ExecuteProgress += (sender, args) =>
{
this.executeProgress = args.OverallPercentage;
this.Progress = (this.cacheProgress + this.executeProgress) / 2;
};
minaClient = …Run Code Online (Sandbox Code Playgroud) 我有一个字符串,如下所示.
{(firstName1,lastName1,College1,{(24,25)},{(Street,23)},City1,Country1)}
Run Code Online (Sandbox Code Playgroud)
我需要从上面提取细节/值并将它们添加到列表中.我的意思是:
["firstName1","lastName1","College1","24","25","Street","23","City1", "country1"]
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现上述目标?我尝试了下面的方法,但不知道如何将所有花括号和括号放入模式中.
private static String flattenPigBag(String pigdata) {
String s = "";
Pattern p = Pattern.compile("\\{(.*)}");
Matcher m = p.matcher(pigdata);
while (m.find()) {
s = m.group(1);
System.out.println("answer : " + s);
}
return s;
}
Run Code Online (Sandbox Code Playgroud) 我编写了一个 bash 脚本,它按名称获取参数并读取键值对中的值。下面是我如何运行脚本的示例。
sh test.sh param1='a' param2='b'
Run Code Online (Sandbox Code Playgroud)
然后,我在脚本中引用 $param1 和 $param2 等输入参数。下面是我为此编写的脚本。
for item in $@; do
case $item in
(*=*) eval $item;;
esac
done
Run Code Online (Sandbox Code Playgroud)
但是当参数值中有空格时,它只取空格之前的部分。
param3='select * from'
Run Code Online (Sandbox Code Playgroud)
只会将“select”分配给 param3 而不是整个字符串。我怎样才能实现这个目标?任何帮助将非常感激。
编辑 :
伊尼安回答后
for item in $@; do
case "$item" in
(*=*) eval "$item";;
esac
done
Run Code Online (Sandbox Code Playgroud) 我有下面的 ObjectNode。
handlerObjectNode -> {"Info":{"Brand":{"BrandName":"TOP OF THE WORLD"}}}
Run Code Online (Sandbox Code Playgroud)
我有另一个以下格式的 ObjectNode。
fieldObjects -> {"Description":"REGULAR BR"}
Run Code Online (Sandbox Code Playgroud)
如何从上面两个创建下面的 ObjectNode?
{
"Info": {
"Brand": {
"BrandName": "TOP OF THE WORLD"
}
"Description": "REGULAR BR"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了下面的代码。
handlerObjectNode.setAll(fieldObjects);
Run Code Online (Sandbox Code Playgroud)
但它会产生以下 ObjectNode。
{
"Info": {
"Brand": {
"BrandName": "TOP OF THE WORLD"
}
},
"Description": "REGULAR BR"
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Jackson 的 com.fasterxml.jackson.databind.node.ObjectNode 。任何帮助将非常感激。
java ×6
bash ×1
bootstrapper ×1
burn ×1
c ×1
crc ×1
crc16 ×1
data-binding ×1
ecmascript-6 ×1
fasterxml ×1
jackson ×1
jar ×1
javascript ×1
jenkins ×1
jestjs ×1
json ×1
linux ×1
locking ×1
logback ×1
logging ×1
matcher ×1
maven ×1
reactjs ×1
regex ×1
shell ×1
slf4j ×1
spring ×1
spring-boot ×1
string ×1
teamcity ×1
terminal ×1
timer ×1
tslint ×1
types ×1
typescript ×1
ubuntu-16.04 ×1
wix ×1
wix3.10 ×1
wpf ×1
xor ×1
yarnpkg ×1