简体   繁体   中英

Package not found error when building the maven project

I have created a maven project and i am going to use a .jar file that already created by someone. I have added it into the class path and used it and there are no errors showing in eclipse. But when i try to clean build the project there is an error as follows.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project DigitalWallet: Compilation failure: Compilation failure: [ERROR] /E:/DigitalWallet_V0.1/DigitalWallet/src/main/java/com/MobiOs/config/Log4jConfig.java:[11,23] package com.mobios.util does not exist [ERROR] /E:/DigitalWallet_V0.1/DigitalWallet/src/main/java/com/MobiOs/config/Log4jConfig.java:[25,17] cannot find symbol [ERROR] symbol: variable LogUtil [ERROR] location: class com.MobiOs.config.Log4jConfig [ERROR] /E:/DigitalWallet_V0.1/DigitalWallet/src/main/java/com/MobiOs/config/Log4jConfig.java:[26,17] cannot find symbol [ERROR] symbol: variable LogUtil [ERROR] location: class com.MobiOs.config.Log4jConfig [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

It saying the package com.mobios.util does not exist.

    @Configuration
    @EnableTransactionManagement
    @ComponentScan({ "com.MobiOs.config", "com.mobios.util" })
    public class Log4jConfig {
        @Bean
        public void initilizeLog4j() throws UnsupportedEncodingException {
        LogUtil.init("/conf/log4j.xml");
        LogUtil.getEventLog().debug("Kasun" + 
        ",SERVICE_INITIALIZED,initialized_logs,,");
        }
    }

In web Config i have set the component scan also`

@Configuration
@EnableWebMvc
@ComponentScan({ "com.MobiOs", "com.mobios" })
    public class WebConfig {
    }

But i am getting the above error.

Note : My package name is com.MobiOs.config But the imported jar package name is com.mobios.util

You have two packages with same case insensitive names com.MobiOs to com.mobios which represent physically two directories with same case insensitive names. This can lead to an issue if your file system is case insensitive, or expect specific case as lower case.

Java's package names should be lower case:

Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

If you are not convinced, see comment :

On some versions of some Windows file systems names that are entered in all caps are displayed in all lowercase as the default. This is probably to be friendly towards files from systems that don't distiguish case — these may come in in all uppercase and look better in all lowercase. While the file name is still uppercase behind the scenes, this may have caused confusion

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM