San*_*jee 65 java intellij-idea
我是第一次使用IntelliJ IDEA Community Edition并使用Maven来设置TDD环境.我试图测试的代码和我遇到的警告消息以及项目结构如下所示.
package miscellaneous;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestHello {
// Methods to be tested.....
private int Add1Plus1(int i, int j) {
return (i + j);
}
@Test
public void testAdd1Plus1() throws Exception {
assertEquals(2, Add1Plus1(1, 1));
}
}
Run Code Online (Sandbox Code Playgroud)
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
Run Code Online (Sandbox Code Playgroud)
导致这些消息的原因是什么以及修复这些警告消息的好方法?
Bro*_*rod 65
我做了上述所有操作,但仍然有一个警告实例:
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Run Code Online (Sandbox Code Playgroud)
我进入了我的project_name.iml文件并替换了以下标记:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
Run Code Online (Sandbox Code Playgroud)
有:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
Run Code Online (Sandbox Code Playgroud)
瞧,没有更多的错误信息.希望这有助于某人.
Edu*_*sov 15
如果是使用Maven的项目,请检查pom.xml文件中的源和目标:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
如果您有Maven项目,请打开pom.xml文件,并在项目根目录内添加以下代码:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
38047 次 |
最近记录: |