[IDEA] idea does not automatically generate target


This article describes several situations where the idea does not generate a target and how to deal with it

1. Do not generate target

If the target folder is not generated at all like the picture below, first consider the environmental issues. Have you imported the project into the idea correctly, whether jdk has been configured, etc.

It is obvious from the picture above that the module p6spy shows a normal folder instead of a maven project.

Solution:

Correctly import the maven project to the idea (if the project folder shows no small squares, the project has been imported correctly) and try again

2. Only some files do not generate target

2.1. The general reason is that the resource is not set

For example, in common maven projects, the category of resources must be marked, otherwise it may not be compiled to the target

2.2. Configure and compile resource files under the src/main/java folder

By default, the maven plugin will only package resource files under resources. Commonly, the mybatis resource files we add in the java directory mapper.xmlwill not be packaged into the target by default (as shown in the figure below), and all non-.java files will not be compiled into the target.

Solution:

In this case you need to configure the packaging plugin (as follows)

<build>
    <!-- 资源目录 -->    
    <resources>    
        <resource>    
            <!-- 设定主资源目录  -->    
            <directory>src/main/java</directory>       
            <includes>
                <include>**/*.xml</include>
            </includes>     
            <excludes>  
                <exclude>**/*.yaml</exclude>  
            </excludes>  
            <filtering>true</filtering>     
        </resource>  			
    </resources> 	
</build>

2.3. Clear the cache (Wang Zha)

**Clearing the cache is the king bomb that solves the strange problem of idea interval time! **Every once in a while in the idea, there will be some inexplicable problems related to cleaning the cache, such as:

  • After modifying the java file, the original code still runs
  • maven clean packageCompile new code every time a java file is modified

When encountering a problem similar to the above, we just cleared the cache and restarted, and restarted when we returned from fishing in the toilet! The solution is as follows:

3. References

idea does not automatically generate target

Maven configures domestic mirroring

Guess you like

Origin blog.csdn.net/yuchangyuan5237/article/details/131983186