是否可以在 commonMain 中定义数据类型的期望,然后在 jvmMain 或 jsMain 中提供实际的数据类型?
例如,假设我想在 commonMain 类中使用 JavaScript 和 Java 中日期的本地数据类型:
// commonMain
expect datatype Date
// jsMain
actual datatype Date = Date()
// jvmMain
actual datatype Date = LocalDate()
Run Code Online (Sandbox Code Playgroud)
这样的事可能吗?如果是的话,语法是什么样的?
是否可以使用java邮件在IMAP邮件消息上设置自定义标志而不覆盖现有标志?例如,我需要在已处理的消息上设置"已处理"标志,而不将其状态更改为SEEN/DELETED,或者没有邮件客户端干扰此"已处理"标志.
然后我需要找到所有没有"已处理"标志的邮件并处理它们,之后它们也被标记为"已处理".
谢谢!
我想知道是否有可能在java.net.URL上为DNS查找提供自定义实现 - 我的托管服务提供商的DNS在一天的特定时间变得不稳定,然后DNS查找失败几分钟,但如果我手动配置相关域在我的hosts文件中,它们工作正常,所以我想做的是在软件级别有一些DNS缓存,如果DNS查找成功,更新缓存,如果失败,则回退到缓存的IP地址并打开对该IP地址进行URLConnection.
这是我的URL连接实现:
URL endpoint = new URL(null, url, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL url)
throws IOException {
URL target = new URL(url.toString());
URLConnection connection = target.openConnection();
// Connection settings
connection.setConnectTimeout(connectionTimeout);
connection.setReadTimeout(readTimeout);
return (connection);
}
});
Run Code Online (Sandbox Code Playgroud)
我正在查看Oracle上的代理,但看不到任何直接的方法在软件级别进行自定义DNS查找.
限制:
1:它需要在Java6中工作(可能是Java7,但客户端不会很快切换到Java8)
2:无法添加JVM args
3:我没有这些端点,因此用IP地址替换主机名不是解决方案,因为负载均衡器将根据您是来自主机名还是IP地址来提供不同的内容/ API.例如:mail.google.com解析为216.58.223.37,转到该IP地址将提供google.com内容而不是mail.google.com内容,因为两个服务都使用单个IP地址位于同一负载均衡器后面.
4:我不知道我需要缓存多少URL的DNS解析,但我知道它不会超过1000.理想的解决方案是将DNS解析在静态hashmap中,如果有的话DNS解析成功,更新hashmap,如果失败,则使用hashmap中的DNS解析.
5:如果有本机java解决方案,我宁愿过度使用JNI - 了解Java中的主机名解析和DNS行为
我习惯使用Spring Roo来生成我的实体,让它通过AspectJ类处理实体管理以及持久化和其他方法.现在我正在尝试使用Spring Boot做一些简单的事情,将事情写入数据库......
@Entity
@Table(name = "account")
public class Account {
transient EntityManager entityManager;
@Id
@GeneratedValue
private Long id;
@Column(name = "username", nullable = false, unique = true)
private String username;
@Column(name = "password", nullable = false)
private String password;
... getters and setters
@Transactional
public void persist() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.persist(this);
}
@Transactional
public Account merge() {
if (this.entityManager == null) this.entityManager = entityManager();
Account merged = this.entityManager.merge(this);
this.entityManager.flush();
return merged;
}
Run Code Online (Sandbox Code Playgroud)
当我调用persist或merge时,entityManager显然是null.
我也尝试添加 …
是否可以阻止返回 future 的函数调用?
\n\n我的印象是调用.then()可以做到这一点,但这不是我在输出中看到的。
print("1");\nHttpRequest.getString(url).then((json) {\n print("2");\n});\nprint("3");\nRun Code Online (Sandbox Code Playgroud)\n\n我在输出中看到的是:
\n\n1\n3\n2\nRun Code Online (Sandbox Code Playgroud)\n\n该getString方法没有async允许我执行的方法await,并且then在任何情况下都会异步执行。
static Future<String> getString(String url,\n {bool withCredentials, void onProgress(ProgressEvent e)}) {\n return request(url, withCredentials: withCredentials,\n onProgress: onProgress).then((HttpRequest xhr) => xhr.responseText);\n }\nRun Code Online (Sandbox Code Playgroud)\n\n如何使其阻塞,而不在步骤 3 之前放置无限 while 循环等待步骤 2 完成(并不是说由于 Dart 的单线程性质,它无论如何都会工作)?
\n\n上面的 HttpRequest 加载一个config.json文件,该文件决定应用程序中的所有内容如何工作,如果在文件加载完成之前完成对配置中字段的请求config.json,则会导致错误,因此我需要等到文件加载完成后再进行允许在类的字段上调用 getter,或者 getter 需要等待文件的一次性加载config.json。
更新,这就是我在 G\xc3\xbcnter 建议我使用之后最终使其工作的方法Completer:
@Injectable()\nclass ConfigService {\n\n …Run Code Online (Sandbox Code Playgroud) 是否可以从外部URL加载模板?这就是我目前正在尝试做的事情,但Angular似乎忽略了它而没有抛出任何错误,并且页面只是无限期地继续加载.
@Component(
selector: 'dashboard-page',
//templateUrl: '../templates/dashboard-page.html',
templateUrl: 'http://localhost:9091/html/dashboard-page.html',
directives: const [],
pipes: const []
)
class DashboardPage implements AfterContentInit {
Run Code Online (Sandbox Code Playgroud)
http://localhost:9091/html/dashboard-page.html 我可以直接访问并设置CORS以允许端口8080上的Dart应用程序与端口9091上的Kotlin应用程序通信.
我正在尝试根据帐户配置文件加载不同的HTML模板 - 不同的帐户会看到Kotlin代码提供的不同HTML模板.
我这个可以完成或不可能让Angular2加载外部模板文件的东西?
我正在尝试将工件发布到~/.m2(maven-local),作为 Gradle 新手,我不确定我错过了什么
到目前为止我看到的所有示例都建议使用一个publishing块,当我运行任何 Gradle 命令时,该块会引发弃用警告。还包括maven-publish没有任何publishing阻止的插件会导致相同的警告。
repositories {
mavenLocal()
jcenter()
}
plugins {
`maven-publish`
kotlin("jvm") version("1.3.10")
id("org.jetbrains.dokka") version "0.9.16"
}
Run Code Online (Sandbox Code Playgroud)
作为使发布插件稳定的一部分,“发布 {}”块的“延迟配置”行为已被弃用。在 Gradle 5.0 中,“enableFeaturePreview('STABLE_PUBLISHING')”标志将被删除,新行为将成为默认行为。请将“enableFeaturePreview('STABLE_PUBLISHING')”添加到您的设置文件中,并通过发布到本地存储库来进行测试运行。如果所有工件都按预期发布,则无需执行其他操作。如果已发布的工件发生意外更改,请参阅迁移指南以获取更多详细信息: https: //docs.gradle.org/4.10.2/userguide/publishing_maven.html#publishing_maven :deferred_configuration。
如果它实际上发布到 maven-local,我可能会暂时忽略该警告,但它根本没有发布,也没有gradle publishToMavenLocal,它只是简单地显示BUILD SUCCESSFUL in __s了上述警告。
publishing尝试在块内添加块的推荐路线(根据链接)subprojects会导致 intellij 中出现大量红色
不确定这是否是 Kotlin DSL ...尝试 Gradle 文档的 Kotlin DSL 版本上显示的其他内容:
知道我缺少什么吗?
这是我的 Gradle 版本和其他相关信息(IntelliJ 有 Kotlin 3.1.0)
gradle -version
------------------------------------------------------------
Gradle 4.10.2
------------------------------------------------------------
Build time: 2018-09-19 18:10:15 UTC
Revision: …Run Code Online (Sandbox Code Playgroud) 我正在将一个项目打包成一个docker jetty图像,我正在尝试访问日志,但没有日志.
Dockerfile
FROM jetty:9.2.10
MAINTAINER Me "me@me.com"
ADD ./target/abc-1.0.0 /var/lib/jetty/webapps/ROOT
EXPOSE 8080
Run Code Online (Sandbox Code Playgroud)
用于启动docker镜像的Bash脚本:
docker pull me/abc
docker stop abc
docker rm abc
docker run --name='abc' -d -p 10908:8080 -v /var/log/abc:/var/log/jetty me/abc:latest
Run Code Online (Sandbox Code Playgroud)
图像正在运行,但我没有看到任何码头登录/var/log.
我试过了docker run -it jetty bash,但没有看到任何码头登录/var/log.
我错过了一个参数来制作码头输出日志,还是将它输出到除了/var/log/jetty?
我正在尝试使用 Java 连接到 Google Compute Engine,但出现的异常对我来说意义不大。
我下面的例子说明了以下内容:
/** Authorizes the installed application to access user's protected data. */
private static Credential authorize() throws Exception {
// load client secrets
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY,
new InputStreamReader(CalendarSample.class.getResourceAsStream("/client_secrets.json")));
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, JSON_FACTORY, clientSecrets,
Collections.singleton(CalendarScopes.CALENDAR)).setDataStoreFactory(dataStoreFactory)
.build();
// authorize
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
}
Run Code Online (Sandbox Code Playgroud)
为了获取包含凭据的 json 文件,我访问 cloud.google.com,转到控制台中的我的应用程序,然后单击凭据,然后单击Create new ClientId、选择Service Account和JSON Key。
这会下载一个_________.json文件。
在 a 中 …
java google-api-java-client google-compute-engine google-oauth
我有点困惑为什么ngAfterContentInit在这种情况下执行两次.我已经创建了我们的应用程序的精简版本来重现该错误.简而言之,我使用a *contentItem来标记组件,然后由standard-layout组件拾取以进行渲染.只要我遵循这个模式,demo的ngAfterContentInit执行两次.
我将演示应用程序放在github上,这将重现错误:https: //github.com/jVaaS/stackoverflow/tree/master/ngaftercontentinit
否则这里是重要的一点:
越野车,app.dart:
@Component(
selector: "buggy-app",
template: """
<standard-layout>
<demo *contentItem></demo>
</standard-layout>
""",
directives: const [
ContentItemDirective,
StandardLayout,
Demo
]
)
class BuggyApp implements AfterContentInit {
@override
ngAfterContentInit() {
print(">>> ngAfterContentInit: BuggyApp");
}
}
Run Code Online (Sandbox Code Playgroud)
标准layout.dart:
////////////////////////////////////////////////////////////////////////////////
///
/// Standard Layout Component
/// <standard-layout></standard-layout>
///
@Component(
selector: "standard-layout",
template: """
<div *ngFor="let item of contentItems ?? []">
<template [ngTemplateOutlet]="item.template"></template>
</div>
""",
directives: const [ROUTER_DIRECTIVES, ContentItem])
class StandardLayout implements AfterContentInit …Run Code Online (Sandbox Code Playgroud) java ×4
dart ×3
angular ×2
kotlin ×2
angular-dart ×1
caching ×1
dns ×1
docker ×1
dockerfile ×1
email ×1
google-oauth ×1
gradle ×1
imap ×1
jakarta-mail ×1
jetty ×1
jpa ×1
spring ×1
spring-boot ×1
spring-data ×1