Nice programing

Java 프로젝트를 빌드하는 동안 IntelliJ IDEA에서 경고 메시지 제거

nicepro 2020. 11. 19. 21:59
반응형

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));
    }
}

구성 세부 정보 :

  • 자바 컴파일러 : 1.8.0_45
  • Maven 버전 : 3.0.5
  • Maven 사용자 설정 파일 경로 : /home/sandeep/Desktop/MyDocs/repos/git-repos/public/MavenCodeBase/settings.xml
  • Maven 로컬 저장소 경로 : / home / sandeep / Desktop / MyDocs / repos / maven-repos
  • pom.xml : http://pastebin.com/462Uytad

경고 메시지 :

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.

질문:

이러한 메시지의 원인은 무엇이며 이러한 경고 메시지를 수정하기위한 좋은 / 권장 방법은 무엇입니까?


pom.xml 에서 Java 버전을 확인하십시오 ( 여기에서 방법을 찾을 수 있습니다). 또한 프로젝트 구조 에서 Java 버전을 확인하십시오 . 그리고 마지막으로 할 수있는 일-예를 들어 컴파일러 버전 확인

여기에 이미지 설명 입력


위의 모든 작업을 수행했지만 여전히 경고가 한 번 발생했습니다.

Warning:java: source value 1.5 is obsolete and will be removed in a future release

project_name.iml 파일로 이동하여 다음 태그를 바꿨습니다 .

<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">

와:

<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">

그리고 짜잔, 더 이상 오류 메시지가 없습니다. 이것이 누군가를 돕기를 바랍니다.


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>

제 경우에는 위의 솔루션 중 어느 것도 작동하지 않았습니다. 그러나 프로젝트 구조의 언어 수준을 변경했습니다.

파일-> 프로젝트 구조-> 프로젝트 설정-> 모듈-> "소스"탭에서 언어 수준을 일부 상위 버전으로 변경합니다.

여기에 이미지 설명 입력


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>

Java의 Gradle 프로젝트 에서이 문제가 발생했습니다.

build.gradle 파일에 할당이 사용되지 않았다는 경고가 있습니다. sourceCompatibility = 1.5build.gradle 파일 에서 줄을 제거 하고 모든 경고 메시지가 사라졌습니다.

값 1.5는 더 이상 사용되지 않으며 향후 릴리스에서 제거 될 예정입니다.

참고 URL : https://stackoverflow.com/questions/30690295/removing-warning-messages-on-intellij-idea-while-building-java-project

반응형