我最近将我的机器升级到最新版本的java 6,并在构建项目时不断收到此错误.这有什么意义吗?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project
biz.minaret: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: invalid target release: 1.6.0_45
[ERROR] Usage: javac <options> <source files>
[ERROR] use -help for a list of possible options
Run Code Online (Sandbox Code Playgroud)
我的pom的一部分看起来像这样
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.6.0_45</source>
<target>1.6.0_45</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我的JAVA_HOME设置正确:
PS C:\ Users\me\Documents\m
Documents\myproject> java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed …Run Code Online (Sandbox Code Playgroud) 所以我有以下重载方法:
private static void foo(short... a)
{
System.out.println("Calling var-len");
}
private static void foo(int a, int b)
{
System.out.println("Calling int-int");
}
private static void foo(int a, double b) //(3)
{
System.out.println("Calling int-double");
}
private static void main (String[] args)
{
foo((short)2, (short)5); //This one outputs "Calling int-int"
}
Run Code Online (Sandbox Code Playgroud)
我知道变量arity方法在方法解析阶段具有最低优先级,所以在这种情况下如果我调用foo((short)2, (short)4);我会得到"Calling int-int".
但是,如果我将方法(3)更改为foo(short a, double b),则选择变量arity方法!(Java 7).有人能解释一下吗?
我不想限制BigDecimal中的有效位数.我只想查找该数字的有效位数.
有没有办法在不将数字转换为字符串并计算数字字符的情况下执行此操作?
有没有办法将带有其他参数的POST请求从一个控制器转发到另一个控制器?
假设我有这样的表格:
<form action"${contextPath}/controller1/post">
<input name="field1" type="text"/>
<input name="field2" type="text"/>
<input value="submit" type="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
该表格将发布到controller1.post()方法。
但是现在我有了另一个控制器- controller2也有一个post方法。我现在要发布到,controller2.post因此可以在转发到之前向请求中添加一些参数controller1。有没有办法做到这一点?
是否有类似于C中的Java的Integer.MIN_VALUE,它给出了有符号整数的最小可能值,或者我只需要自己对该值进行硬编码?
我正在使用 BigDecimal 来处理我的应用程序中的正数,我想让它在第 4 个小数之后截断小数。我似乎几乎用 RoundingMode.DOWN 找到了我想要的东西,但是当 BigDecimal 从 double 创建时会出现一些问题。
例如:
System.out.println("123.11119 = " + new BigDecimal("123.11119").setScale(4, RoundingMode.DOWN)); //Print 123.1111 which is exactly what I want
System.out.println("123.1111 = " + new BigDecimal("123.1111").setScale(4, RoundingMode.DOWN)); //So does this one
Run Code Online (Sandbox Code Playgroud)
但是,以下打印123.1110完全不是我想要的:
System.out.println("123.1111 = " + new BigDecimal(123.1111d).setScale(4, RoundingMode.DOWN));
Run Code Online (Sandbox Code Playgroud) 给我一个通信器,我如何获得该通信器中所有处理器的等级?
我能找到的只是如何获取给定通信器中的处理器数量,但似乎没有获取排名集合的功能。
mysql> CREATE database testing CHARACTER SET utf16;
Query OK, 1 row affected (0.00 sec)
mysql> USE testing;
Database changed
mysql> CREATE TABLE t (str varchar(64));
Query OK, 0 rows affected (0.43 sec)
mysql> INSET INTO t values ("1234567891234567");
Query OK, 1 row affected (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
=============================
然后我有一段java代码
Connection connection = DriverManager.getConnection(url, usr, pass);
Statement statement = connection.createStatement();
statement.execute("USE testing");
ResultSet rst = statement.executeQuery("SELECT str, LENGTH(str) FROM t;");
while (rst.next())
System.out.print("java length: " + rst.getString(1).length()
+ "\nmysql length: " + rst.getInt(2)); …Run Code Online (Sandbox Code Playgroud) java ×5
bigdecimal ×2
build ×1
c ×1
c++ ×1
compilation ×1
const ×1
double ×1
forward ×1
javac ×1
maven ×1
mpi ×1
mysql ×1
overloading ×1
post ×1
rounding ×1
spring ×1
spring-mvc ×1
string ×1
types ×1