我从互联网上下载了一个源代码,我正在尝试用maven构建它.这是源代码附带的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>myArtifact</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myArtifact</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>myArtifact.Main</mainClass>
</manifest>
</archive>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
mvn install命令正在生成jar文件,但我无法执行此文件,因为缺少依赖项(在此示例中未找到与postgresql依赖项相关的类异常).
我注意到maven已正确下载了依赖项(jar库都在本地maven存储库目录中)但是mvn install并没有将这些库复制到生成的jar文件中.我怎样才能做到这一点?
谢谢.
Java编程语言中是否有与JavaScript unescape函数等效的函数?也就是说,如果我的输入是字符串"I%20need%20help%21",则输出必须是"我需要帮助!",例如.
谢谢!
我在PostgreSQL数据库上有下表(parent_fk是引用同一个表的外键):
id | parent_fk
72 |
342 | 72
583 | 342
Run Code Online (Sandbox Code Playgroud)
我想查询这个表,并通过中间父/子关系发现每个元素到最终父元素的路径.例如,我想获得以下作为SQL查询的答案:
id | parent_fk | path
72 | | 72
342 | 72 | 72;342
583 | 342 | 72;342;583
Run Code Online (Sandbox Code Playgroud)
我读过关于PostgreSQL的CTE(公用表表达式)和递归查询,但我自己还是无法解决这个问题.有任何想法吗?提前致谢.
我正在使用Maven 1.0.2和JDK 1.5一段时间没有任何问题.我决定迁移到JDK 1.6,因此我更改了JAVA_HOME环境变量(在Windows 7系统上),现在我在尝试使用maven(例如cmd中的maven install命令)时收到一条奇怪的错误消息.
java.io.IOException: Cannot run program "command.com": CreateProcess error=2, the
system could not find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:646)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:416)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:427)
at org.apache.tools.ant.taskdefs.Execute.getProcEnvironment(Execute.java
:180)
at org.apache.tools.ant.taskdefs.Property.loadEnvironment(Property.java:
455)
at org.apache.tools.ant.taskdefs.Property.execute(Property.java:359)
at org.apache.tools.ant.Task.perform(Task.java:341)
at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
at com.werken.werkz.jelly.ProjectTag.doTag(ProjectTag.java:112)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
at org.apache.maven.plugin.PluginManager.runScript(PluginManager.java:11
43)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:
647)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
at org.apache.maven.cli.App.doMain(App.java:488)
at org.apache.maven.cli.App.main(App.java:1239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …
Run Code Online (Sandbox Code Playgroud) 我在JBoss 6.0 AS上的localhost上部署了一个应用程序.此应用程序有一个名为ExampleEJB的远程EJB bean.现在我正在尝试编写一个使用ExampleEJB的简单客户端应用程序.此客户端应用程序不会部署在任何应用程序服务器上.我们的想法是编写一个简单的Java SE客户端程序.我写了以下尝试执行查找:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext ic = new InitialContext(env);
Run Code Online (Sandbox Code Playgroud)
在这一点上,我尝试了两种方法.第一种方法是执行直接查找,例如Java EE 6 Tutorial(http://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html):
ExampleEJB exampleEJB = (ExampleEJB) ic.lookup("java:global/myApp/ExampleEJB");
Run Code Online (Sandbox Code Playgroud)
第二次尝试是尝试获取JNDI上下文环境,然后从这个环境中获取所需的bean:
Context envContext = (Context)ic.lookup("java:/comp/env");
envContext.lookup(...)
Run Code Online (Sandbox Code Playgroud)
问题是我收到以下异常:"javax.naming.NameNotFoundException:global not bound"和"javax.naming.NameNotFoundException:comp not bound".我无法按要求执行查找.
有人有线索吗?
maven ×2
build ×1
dependencies ×1
escaping ×1
hierarchy ×1
java ×1
java-ee ×1
javascript ×1
jboss6.x ×1
jdk1.6 ×1
jndi ×1
postgresql ×1
tree ×1