我正在尝试从eclipse运行一个ant脚本,但它失败并显示以下消息:
BUILD FAILED
project_path/build.xml:5:
java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main :
Unsupported major.minor version 51.0
Run Code Online (Sandbox Code Playgroud)
但是,当我从命令行(./ant)运行它时,它按预期运行.
环境信息:
我还将"Ant Home"(在eclipse设置中)设置为与我在命令行中使用的相同.
我在这个问题上搜索了很多,但我似乎找不到任何有用的东西,我可以尝试卸载我目前已安装的所有java(jdk/jre),然后重新安装java 7,但我不想采取这条路线.
有任何想法吗?谢谢!
我正在尝试在 Mac OS 上运行 Java 程序。我为 Mac 安装了 JDK 1.7 版,尽管如此,我还是在执行 Java 程序时出错。所以,我知道我必须在 Mac 中设置 PATH 和 CLASSPATH(环境变量)才能让 Java 程序成功运行。请帮我解决这个问题。
我对 Maven 很陌生。
我正在尝试执行以下操作:
假设我们必须对 A 和 B 进行项目。项目 B 需要使用从 A 导入的 jar 中的一些 classfrom_A 以下是定义:项目 A 的 POM.xml:
<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>A_Group</groupId>
<artifactId>A_Artifact</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>A_Project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Run Code Online (Sandbox Code Playgroud)
这是项目 B 的 POM.xml(取决于 A):
<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>B_Group</groupId>
<artifactId>B_Artifact</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>B_Project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>A_Group</groupId>
<artifactId>A_Artifact</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
这是来自项目 B 的代码片段:
import packageFromA.*;
public class App {
public static void main(String[] args) { …Run Code Online (Sandbox Code Playgroud) 我有几个单独的XML文件,包含TEI中的历史字母.现在我想将它们合并为一个文件,并以日期作为标准.
A1.xml
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="1">
<teiHeader>
<title>Letter 1</title>
<date when="19990202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 1</p>
</text>
</TEI>
Run Code Online (Sandbox Code Playgroud)
和第二个文件,A2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="2">
<teiHeader>
<title>Letter 1</title>
<date when="20010202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 2</p>
</text>
</TEI>
Run Code Online (Sandbox Code Playgroud)
第三个,A3.xml:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="3">
<teiHeader>
<title>Letter 3</title>
<date when="18880101" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 3</p>
</text>
</TEI>
Run Code Online (Sandbox Code Playgroud)
这些文件以连续文件名"A001.xml"到"A999.xml"命名,但不是按所需顺序命名.所以我的首选输出将是单个文件letters.xml:
<?xml version="1.0" encoding="UTF-8"?>
<CORRESPONDENCE>
<TEI xml:id="3">
<teiHeader>
<title>Letter 3</title>
<date when="18880101" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 3</p> …Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能从ZipEntry... 获得简单的名称
当我调用getName()Entry时,我得到一个完整的路径名.
我只需要获取文件的名称.
在这里,我需要获取简单的名称而不是其根的全名.
public class ZipFileSample {
public static void main(String[] args) {
try {
ZipFile zip = new ZipFile(new File("C:\\Users\\Levi\\Desktop\\jessica.zip"));
for (Enumeration e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) e.nextElement();
//Here I need to get the simple name instead the full name with its root
System.out.println(entry.getName());
}
} catch (ZipException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud) 在一个spring上下文中,我发现一些bean引用包含&在bean名称之前.我想知道&春天名字的开头意味着什么.
我在用 grails 2.3.4
但是当我启动我的应用程序时,我得到:
|Server running. Browse to http://localhost:8080/testApplication
....[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context w
ith path [/testApplication] threw exception
java.lang.RuntimeException: It looks like you are missing some calls to the r:la
youtResources tag. After rendering your page the following have not been rendere
d: [defer]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewIns
tance(ReflectiveInterceptor.java:986)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstru
ctor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteN
oUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstru
ctor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor
(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor
(AbstractCallSite.java:190)
at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanity
Filter.groovy:54) …Run Code Online (Sandbox Code Playgroud) 下面是我的输入xml
<ServiceIncident xmlns="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2">
<RequesterID/>
<ProviderID>INC0011731</ProviderID>
<ProviderPriority>4</ProviderPriority>
<WorkflowStatus>NEW</WorkflowStatus>
<Transaction>
<Acknowledge>1</Acknowledge>
<StatusCode>0</StatusCode>
<Comment>String</Comment>
<TransactionName>Problem_Submittal</TransactionName>
<TransactionType>2</TransactionType>
<TransactionDateTime>2012-10-19T16:05:56Z</TransactionDateTime>
<TransactionNumber>2012-10-19T16:05:56Z:1ae9b6a79901fc40fa75c64e1cdcc3b4</TransactionNumber>
<TransactionRouting>MX::ITELLASNINCBRDG</TransactionRouting>
<DataSource>ServiceNow</DataSource>
<DataTarget>NASPGR72</DataTarget>
</Transaction>
</ServiceIncident>
Run Code Online (Sandbox Code Playgroud)
我的要求是我需要将整个输入复制为输出,但输入中的一个字段需要在输出中更改。
下面是我在 xslt 中用于复制输入的代码。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:r2="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
通过在 xslt 中使用上述代码,我可以将整个输入复制为输出,但根据我的要求,我需要映射 TransactionDateTime 而不是硬编码值
<TransactionDateTime>2012-10-19T16:05:56Z</TransactionDateTime>
Run Code Online (Sandbox Code Playgroud)
我需要在事务中使用这个函数而不是硬编码。下面是我的 xslt 代码,但它没有给出输出
<xsl:template match="r2:TransactionDateTime">
<xsl:value-of select="current-dateTime()"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习Spring MVC并尝试一些示例应用程序。我从ServletContext资源[/WEB-INF/config/sdnext-servlet.xml]中收到XML文档中的第14行错误;嵌套的异常是org.xml.sax.SAXParseException; lineNumber:14; columnNumber:61;cvc-elt.1:找不到元素'beans'的声明。由于这个错误,我陷入了困境。请帮助我修复错误。
我的Spring Configuration XML文件:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:property-placeholder location="classpath:resources/database.properties">
</context:property-placeholder>
<context:component-scan base-package="com.spring.hibernate">
</context:component-scan>
<tx:annotation-driven transaction-manager="hibernateTransactionManager">
</tx:annotation-driven>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="jspViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"> </property>
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource">
<property name="driverClassName" value="${database.driver}"></property>
<property name="url" value="${database.url}"></property>
<property name="username" value="${database.user}"></property>
<property name="password" value="${database.password}"></property>
</bean>
<bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory">
<property name="dataSource" ref="dataSource"></property>
<property name="annotatedClasses">
<list>
<value>com.spring.hibernate.model.Employee</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} </prop> …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
class MySelectBox {
public MySelectBox(Provider<Map<? extends Object, ? extends Object>> providerArrayIdToLabel) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
我试图在使用此类的代码中传递此信息:
new MySelectBox(new Provider<Map<Long, String>>{
... my implementation of Provider ...
});
Run Code Online (Sandbox Code Playgroud)
编译器给出以下错误:
The constructor MySelectBox(new Provider<Map<Long,String>>(){}) is undefined
Run Code Online (Sandbox Code Playgroud)
为什么?为什么方法未定义?我应该在构造函数的签名中更改什么才能使其接受Provider<Map<Long, String>>
注意:Provider接口是:
public interface Provider<T> extends javax.inject.Provider<T> {
T get();
}
Run Code Online (Sandbox Code Playgroud)