eclipse 文件没有嵌入的样式表指令:使用 logback 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13401789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No embedded stylesheet instruction for file: error using logback
提问by Robert H
I have the following logback.xml
configuration:
我有以下logback.xml
配置:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logFile.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%-4relative [%thread] %highlight(%-5level) %cyan(%logger{35}) - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
If I edit the config file in eclipse (Juno), I get the following error:
如果我在 eclipse (Juno) 中编辑配置文件,则会出现以下错误:
11:02:54,114 INFO [main] Main - javax.xml.transform.TransformerFactory=null
11:02:54,115 INFO [main] Main - java.endorsed.dirs=C:\Program Files\Java\jre7\lib\endorsed
11:02:54,117 INFO [main] Main - launchFile: C:\Users\roberth\Programming_Projects\eclipse\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\launch\launch.xml
11:02:54,145 FATAL [main] Main - No embedded stylesheet instruction for file: file:/C:/Users/roberth/Programming_Projects/eclipse/javaport/src/logback.xml
org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/C:/Users/roberth/Programming_Projects/eclipse/javaport/src/logback.xml
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:225)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73)
Caused by: org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/C:/Users/roberth/Programming_Projects/eclipse/javaport/src/logback.xml
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:214)
... 2 more
If I delete and recreate the config, sometimes it works, sometimes not. If I edit the file in Notepad++ or another text editor, it works fine. Is this an eclipse issue or am I missing something?
如果我删除并重新创建配置,有时它会起作用,有时不会。如果我在 Notepad++ 或其他文本编辑器中编辑文件,它工作正常。这是日食问题还是我遗漏了什么?
回答by Shivan Dragon
It's an Eclipse bug, I've noticed it too. Make sure that you're running the right Eclipse Runtime config (i.e. if you're clicking on the little green "Play" button on the top, thinking it will re-run the last (valid) Runtime you've ran, re-check (by clicking on the down arrow next to it) to make sure no new Runtime has been created).
这是一个Eclipse错误,我也注意到了。确保您正在运行正确的 Eclipse 运行时配置(即,如果您单击顶部的绿色小“播放”按钮,认为它会重新运行您运行的最后一个(有效)运行时,请重新-检查(通过单击旁边的向下箭头)以确保没有创建新的运行时)。
What I've noticed it that even though I create a perfectly valid run-time pointing to a Java main class and everything, which I run a few times and all is good, after a while, if I select an xml file (because I wanted to edit it for example) and then leave it selected as I click on my run button, Eclipse will create a new XSLT Transformation run time for that xml file and try to run it, failing with the exception you report. The solution is to erase that run time, make sure I have no xml file selected, and re-run the correct run time.
我注意到的是,即使我创建了一个指向 Java 主类和所有内容的完全有效的运行时,我运行了几次并且一切都很好,一段时间后,如果我选择一个 xml 文件(因为我想编辑它),然后在我单击我的运行按钮时将其选中,Eclipse 将为该 xml 文件创建一个新的 XSLT 转换运行时并尝试运行它,但由于您报告的异常而失败。解决方案是清除该运行时,确保我没有选择 xml 文件,然后重新运行正确的运行时。
回答by Michael Kempny
I had the same problem with the newest Eclipse Juno Version. First it seems to be a bug inside Eclipse. After closing the active window inside Eclipse (with the spring-configuration.xml openend) I was able to start the spring container without this error. So it was depending on the run configuration. Take care that you start your "main" class and that you not try to "run" the xml-configuation. That solved the issue for me (Eclipse selected automatically the xml to run).
我在最新的 Eclipse Juno 版本中遇到了同样的问题。首先,它似乎是 Eclipse 中的一个错误。关闭 Eclipse 内的活动窗口(使用 spring-configuration.xml openend)后,我能够启动 spring 容器而不会出现此错误。所以这取决于运行配置。注意启动“主”类并且不要尝试“运行”xml 配置。这为我解决了这个问题(Eclipse 自动选择要运行的 xml)。