본문 바로가기
프로그램/spring framework

spring @Log4j annotation compile 에러 해결

by lunker-empire 2020. 4. 9.

package com.yp.controller;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import lombok.extern.log4j.Log4j;


@Controller

@RequestMapping("/sample/*")

@Log4j

public class SampleController {

@RequestMapping("")

public void basic() {

log.info("basic........");

}

}



[ERROR] -> [Help 1] 

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project controller: Compilation failure 
/D:/DEV/workspace.sp/ex00/src/main/java/com/yp/controller/SampleController.java:[11,1] package org.apache.log4j does not exist 

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) 
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) 
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) 
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957) 
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289) 
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) 
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) 
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) 
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure 
/D:/DEV/workspace.sp/ex00/src/main/java/com/yp/controller/SampleController.java:[11,1] package org.apache.log4j does not exist



>> pom.xml 의  runtime scope 를 제거하면 해결.