我想Map
在Groovy中将我的对象转换为Xml.我已经浏览了当前的例子,我认为这会简单得多!
所有样品我发现,无论是使用一个MarkupBuilder
手动指定的字段,或有一个实用的方法来遍历树.最令人发指的!
有什么我想念的吗?我可以简单地转换这些其他格式......
JsonOutput.prettyPrint(JsonOutput.toJson(map)) // json
(map as ConfigObject).writeTo(new StringWriter()) // groovy
new Yaml().dump(map, new StringWriter()) // yml
Run Code Online (Sandbox Code Playgroud)
为什么我不能这样做?
XmlUtil.serialize(map)
Run Code Online (Sandbox Code Playgroud)
(或者我如何将Map
对象转换为Element
/ Node
/ GPathResult
/ Writable
对象?)
def myMap = [
key1: 'value1',
key2: 'value2',
key3: [
key1: 'value1',
key2: 'value2',
key3: [
key1: 'value1',
key2: 'value2',
]
]
]
Run Code Online (Sandbox Code Playgroud)
<root>
<key1>value1</key1>
<key2>value2</key2>
<key3>
<key1>value1</key1>
<key2>value2</key2>
<key3>
<key1>value1</key1>
<key2>value2</key2>
</key3>
</key3>
</root>
Run Code Online (Sandbox Code Playgroud) 当我尝试在Mac OSX 10.10.5上的Intellij IDEA 15.0.3中编译我的groovy项目时,我当前收到以下错误.(Windows机器上的同一项目不会发生此问题)
信息:Groovyc:java.lang.RuntimeException:错误抓取Grapes - [下载失败:com.google.code.gson#gson; 2.2.4!gson.jar]
JAR存在于repo.maven.org和jcenter.bintray.com中.
我可以下载并在我的项目中明确地使用它compile "com.google.code.gson:gson:2.2.4"
- 我仍然看到这个编译器问题.
我看不出下载失败的原因,我正在使用开箱即用的功能~/.gradle/grapeConfig.xml
.
我已经尝试删除我的grape cache目录并重新下载依赖项 - 适用于我所有明确定义的依赖项.
我在家庭网络 - 没有代理.
我想启用高级日志记录,以便我可以看到Grapes下载失败的确切原因.我已经尝试将groovy.grape.report.downloads=true
系统属性添加到终端(和~/.bashrc
),但无济于事.我在Intellij"Groovy编译器"设置页面中找不到任何设置这些属性的方法.(如果我可以启用Grapes日志记录,我相信我能够看到根本原因)
Intellij项目是从中设置的gradle cleanIdea idea
.当从命令行构建项目时 - gradle clean build
(在Mac和Windows上),应用程序编译时没有错误 - 只有问题出现在Mac上的Intellij中.
这gson.jar
实际上没有在任何@Grab
/ @Grape
注释中引用,我没有检查过,但我猜它是一个传递依赖.
任何帮助将不胜感激!
Information:Using javac 1.8.0_60 to compile java sources
Information:Groovyc: Groovyc stub generation failed
Information:Groovyc: java.lang.RuntimeException: Error grabbing Grapes -- [download …
Run Code Online (Sandbox Code Playgroud) 是否可以@Lazy
初始化Spring @Value
?
例如
@Lazy
@Value("${someConfig}")
private String someConfig;
Run Code Online (Sandbox Code Playgroud)
我特别提到的场景是一个通过JNDI设置的变量,以及一个嵌入式Tomcat容器,它在Spring Boot加载过程中初始化了一些JNDI变量 ......其他场景我可以想到你想要的位置JIT变量填充:检索变量"昂贵"并且您不希望影响启动时间,该变量在应用程序启动时不可用等.
上面的代码给出了以下错误:
java.lang.IllegalArgumentException:无法继承final类java.lang.String
我想你可以通过使用@ConfigurationProperties
bean来实现延迟加载的变量?
一个跟进问题:如果基础变量源发生了变化(例如服务器上的JNDI),是否可以/将@Value
初始化的变量重新初始化(没有重新启动应用程序)?即重新检索
(我正在尝试最后两个场景)
我遇到的问题是,我想在 SpringBoot 的bootRun
gradle 任务中包含测试类路径资源。为什么?这样我就可以使用test
带有测试资源的配置文件来模拟集成点。
我试过的:
addResources = true
选项(我尝试使用customConfiguration
按照类似的bootRepackage
配置,但没有成功)BootRunTask
useTestClasspath
(在 gradle 版本中没有镜像)使用spring-boot
and jetty
,我希望能够将我的应用程序配置为侦听其他端口,这些端口在运行时以编程方式添加(+ 删除?)。
我试过的:
我遵循了本教程,它允许我侦听多个端口。这很完美,但不幸的是仅在启动时有效。
我已经尝试@Autowiring
了org.eclipse.jetty.server.Server
一个服务类,以便我可以添加连接器 - 我收到了错误No qualifying bean of type [org.eclipse.jetty.server.Server] found ...
build.gradle(依赖项
buildscript {
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE")
}
}
apply plugin: 'spring-boot'
...
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.eclipse.jetty:jetty-proxy:9.2.17.v20160517"
...
Run Code Online (Sandbox Code Playgroud)
不知道从这里尝试什么......
我正在尝试向 a 的背景添加模糊效果dialog
(我意识到dialog
目前只有有限的支持 - 我正在使用Chrome v66
)。
我尝试在::backdrop
css 中添加模糊过滤器(没有运气),但backdrop-filter
尚不支持。
有人知道我应该做什么吗?
window.onload = function() {
document.getElementById('mydialog').showModal();
}
Run Code Online (Sandbox Code Playgroud)
dialog::backdrop {
background: rgba(255, 0, 0, .25);
}
/* attempt #1 - using a blur filter */
dialog::backdrop {
-webkit-filter: blur(2px);
-moz-filter: blur(2px);
-o-filter: blur(2px);
-ms-filter: blur(2px);
filter: blur(2px);
}
/* attempt #2 - using backdrop-filter */
dialog::backdrop {
-webkit-backdrop-filter: blur(2px);
backdrop-filter: blur(2px);
}
/* attempt #3 - using an svg */
dialog::backdrop {
background-image: …
Run Code Online (Sandbox Code Playgroud)在 NodeJS 中的客户端上调用 SOAP 方法时,我收到以下通用 TypeScript 错误node-soap
。我如何解决它?
0.35.0
示例代码
const [result] = await mySoapClient.Perform_Operation({ ... })
Run Code Online (Sandbox Code Playgroud)
错误
TypeError: callback is not a function
at /Users/nick/node_modules/soap/lib/client.js:203:17
at parseSync (/Users/nick/node_modules/soap/lib/client.js:305:24)
at /Users/nick/node_modules/soap/lib/client.js:466:24
at Request._callback (/Users/nick/node_modules/soap/lib/http.js:171:17)
at Request.self.callback (/Users/nick/node_modules/request/request.js:185:22)
at Request.emit (events.js:223:5)
at Request.EventEmitter.emit (domain.js:475:20)
at Request.<anonymous> (/Users/nick/node_modules/request/request.js:1154:10)
at Request.emit (events.js:223:5)
at Request.EventEmitter.emit (domain.js:475:20)
at IncomingMessage.<anonymous> (/Users/nick/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:312:28)
at IncomingMessage.emit (events.js:228:7)
at IncomingMessage.EventEmitter.emit (domain.js:475:20)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Run Code Online (Sandbox Code Playgroud) 使用过滤器(DelegatingFilterProxy)安装SpringBoot Legacy(web.xml)WAR应用程序时,我收到以下错误/ stacktrace:
java.lang.IllegalStateException:org.springframework.boot.legacy.context.web.AnnotationConfigNonEmbeddedWebApplicationContext@fff88888尚未刷新
[ERROR] 2016-01-11 11:11:11,265 org.springframework.web.servlet.DispatcherServlet - Context initialization failed
java.lang.IllegalStateException: org.springframework.boot.legacy.context.web.AnnotationConfigNonEmbeddedWebApplicationContext@fff88888 has not been refreshed yet
at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1041)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1059)
at org.springframework.web.servlet.DispatcherServlet.initMultipartResolver(DispatcherServlet.java:497)
at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:479)
at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:471)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:559)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:342)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1375)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1024)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3815)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:981)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:456)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:518)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:309)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:280)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1049)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:643)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) …
Run Code Online (Sandbox Code Playgroud) 这可能是一项不可能完成的任务,但这里......
spring-boot
应用程序的类路径来注册spring bean ?场景:我想创建一个非侵入式plugin
jar,当导入到spring-boot
项目的类路径中时,它将自动被拾取并提供服务(例如通过a RestController
).
spring-boot
应用程序(即没有其他扫描路径或bean配置).spring-boot
应用程序的包结构/扫描路径一无所知.我想我希望默认情况下Spring扫描它自己的包结构(即org.springframework.**
寻找数据库库的存在等),我可以捎带它 - 我没有运气(到目前为止).
我在github中设置了一个示例项目,以进一步阐明/说明我的示例和尝试.
让它工作的这个位是添加以下文件,它指向一个@Configuration
配置文件......
插件-POC的\ src \主\资源\ META-INF\spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.thirdpartyplugin.PluginConfiguration
Run Code Online (Sandbox Code Playgroud) 给定以下生成a的代码片段,UUID.randomUUID()
我得到以下性能结果(以毫秒为单位):
public static void main(String[] args) {
long tmp = System.currentTimeMillis();
UUID.randomUUID();
tmp = printDiff(tmp);
UUID.randomUUID();
tmp = printDiff(tmp);
UUID.randomUUID();
tmp = printDiff(tmp);
UUID.randomUUID();
tmp = printDiff(tmp);
}
private static long printDiff(final long previousTimestamp) {
long tmp = System.currentTimeMillis();
System.out.printf("%s%n", tmp - previousTimestamp);
return tmp;
}
Run Code Online (Sandbox Code Playgroud)
结果:
971
6
0
0
Run Code Online (Sandbox Code Playgroud)
JDK: 1.8 操作系统: Windows 7
为什么只有初始通话需要这么长时间?(将近1秒!)
NPM 库: "mongodb": "3.1.4"
尝试批量插入数据列表时出现以下错误:
代码:
db.collection('products').insertManyAsync(products, {ordered: false})
Run Code Online (Sandbox Code Playgroud)
错误:
操作无效,未指定操作
java ×7
spring-boot ×5
groovy ×2
javascript ×2
spring ×2
css ×1
css-filters ×1
dialog ×1
drools ×1
gradle ×1
html ×1
jetty ×1
mongodb ×1
node-soap ×1
node.js ×1
npm ×1
performance ×1
uuid ×1
websphere ×1
websphere-8 ×1
xml ×1