有没有办法${basedir}在我的pom.xml中获取父目录?目前我有
<earSourceDirectory>${basedir}/EAR/src/main/resources</earSourceDirectory>
Run Code Online (Sandbox Code Playgroud)
但我需要访问basedir的父目录,因为我的资源位于不同的maven项目中.
如何获取$的父文件夹{basedir}?
我需要对此进行清楚的解释,即使我读到这个关于差异的链接但没有明确的清晰度.所以任何人都可以用代码向我解释这一点.
我正在尝试使用java 9和gradle的spring boot.我无法运行我的简单代码,我得到以下提到的错误: -
Information:java: Errors occurred while compiling module 'Java9Gradle_main'
Information:javac 9-ea was used to compile java sources
Information:6/9/2017 10:40 PM - Compilation completed with 65 errors and 0 warnings in 15s 200ms
Error:java: module reads package org.apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:java: module reads package org.apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:java: module spring.boot.starter.web reads package org.apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:java: module spring.boot.starter.web reads package org.apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:java: module spring.boot.autoconfigure reads …Run Code Online (Sandbox Code Playgroud) Java的ServiceLoader类现在已经被正式编入Java语言.META-INF/services现在可以使用.而不是在寻找提供商
provides <spiClass> with <providerClass>
Run Code Online (Sandbox Code Playgroud)
我无法理解的是,uses在服务加载模块声明中的使用:
uses <spiClass>
Run Code Online (Sandbox Code Playgroud)
引用模块系统的状态
模块系统可以通过扫描模块工件中的类文件来识别
ServiceLoader::load方法的调用来识别服务的使用 ,但这既缓慢又不可靠.模块使用特定服务是该模块定义的一个基本方面,因此为了效率和清晰度,我们在模块的声明中用uses子句表示:module java.sql { requires transitive java.logging; requires transitive java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; uses java.sql.Driver; }
为什么模块系统了解特定服务的使用是否至关重要,尤其是如何引入效率?是不是懒洋洋地加载服务?为什么服务加载器不能直接寻找提供商?
Spring 5被宣传为"支持JDK 9",同时Spring 4.3.13的文档声明它支持Java 8(以及6和7).
这是否意味着我需要在可以之前升级到Spring 5
我正在开发一个本地Maven项目.如何jshell使用包含所有依赖项的项目类路径启动,以便我可以在JShell中测试项目或依赖项类.
我花了一些时间将我用Groovy编写的项目迁移到Java 10.现在可以编译并运行它.但它仍然没有使用Java 9模块化的任何好处.
谷歌搜索Groovy和Java 9模块几乎没有.
那么是否可以迁移Groovy项目以使用带有Project Jigsaw模块的JDK 10?
当在第33行重新声明Integer'a'时,为什么jshell将引用变量显示为Integer的实例(参考第38和39行)?重新声明后,第34行显示'a'设置为null.当'a'在第6行声明但未给出值时,或在第22行中重置为null时,'a'不被视为Integer的实例.我希望当引用变量被重新声明时,因为它的值为null,所以它不是一个类型的实例; 然而,事实并非如此.
01: java-lava:~ cafedude$ jshell
02: | Welcome to JShell -- Version 11
03: | For an introduction type: /help intro
04:
05: jshell> Integer a;
06: a ==> null
07: | created variable a : Integer
08:
09: jshell> a instanceof Integer;
10: $2 ==> false
11: | created scratch variable $2 : boolean
12:
13: jshell> a = 1;
14: a ==> 1
15: | assigned to a : Integer
16:
17: jshell> a instanceof Integer;
18: …Run Code Online (Sandbox Code Playgroud) 我有Java 11 JDK和IntelliJ IDEA 2018.2.4(64位).当我使用Java 10.0.2时,IntelliJ IDEA中的JShell控制台工作正常.现在我已升级到Java 11,JShell控制台已停止工作.单击"运行"按钮或按Ctrl + Enter(参见屏幕截图)时,什么都没发生.
我的项目使用Java 11编译和运行很好 - 它只是JShell控制台不起作用.(此外,JShell在命令提示符下运行正常,它只在IDEA内部无效.)我可以在两台机器上重现这个问题,一台在家运行IDEA Community Edition 2018.2.4,另一台在运行Ultimate 2018.2的工作0.3.
我需要做一些配置来解决这个问题吗?
我编写了一个java例程来比较2个二叉树.我正在寻找在更短的时间内运行的更好的算法.
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
class Solution {
public boolean isSameTree(TreeNode p, TreeNode q) {
if ( p == null && q==null)
return true;
if (p == null || q == null)
return false;
if ( (p.val == q.val) && isSameTree(p.left, q.left) &&
isSameTree(p.right, q.right))
return true;
else
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我的代码需要O(n log n)时间.
如何减少所需的时间?
java ×8
java-9 ×5
java-module ×3
jshell ×3
java-11 ×2
maven ×2
spring ×2
spring-boot ×2
algorithm ×1
binary-tree ×1
classpath ×1
gradle ×1
groovy ×1
instanceof ×1
java-8 ×1
java-platform-module-system ×1
module-info ×1
optional ×1