注意事项

maven 项目注意事项

  1. c3p0-config.xml 配置文件必须放在 resources 文件中

  2. maven 项目中 target 目录默认不会排出 xml 文件,需要在 pom.xml 文件中添加属性,手动设置

    <build>
                <!--   默认不包含 xml 文件 ,手动设置 将所有的资源都复制到target目录下面    ${basedir} 表示项目根目录 -->  
                <resources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                        <excludes>
                            <exclude>**/*.java</exclude>
                        </excludes>
                    </resource>
                </resources>
    
        </build>
    
  3. 我的 pom.xml 文件

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>frame_based</groupId>
        <artifactId>frame_based</artifactId>
        <version>1.0-SNAPSHOT</version>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                    </configuration>
                </plugin>
            </plugins>
    
    
                <!--    将所有的资源都复制到target目录下面 ,默认不包含 xml 文件     -->
                <resources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                        <excludes>
                            <exclude>**/*.java</exclude>
                        </excludes>
                    </resource>
                </resources>
    
        </build>
    
    
        <dependencies>
    
    
            <dependency>
                <!--  c3po 依赖              -->
                <groupId>c3p0</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.1.2</version>
            </dependency>
    
    
            <!--  hutool 工具类      -->
            <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-all</artifactId>
                <version>4.5.15</version>
            </dependency>
    
    
            <dependency>
                <!-- fastJson            -->
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.68</version>
            </dependency>
    
    
            <dependency>
                <!--  junit 单元测试          -->
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>RELEASE</version>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <!--  MySQL  驱动         -->
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.20</version>
            </dependency>
    
            <dependency>
                <!-- dom 解析           -->
                <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
                <version>1.6.1</version>
            </dependency>
    
            <!-- servlet -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- jsp -->
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>2.3.1</version>
                <scope>provided</scope>
            </dependency>
            <!-- jstl -->
            <dependency>
                <groupId>javax.servlet.jsp.jstl</groupId>
                <artifactId>jstl-api</artifactId>
                <version>1.2</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.servlet.jsp</groupId>
                        <artifactId>jsp-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.glassfish.web</groupId>
                <artifactId>jstl-impl</artifactId>
                <version>1.2</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.servlet.jsp</groupId>
                        <artifactId>jsp-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.servlet.jsp.jstl</groupId>
                        <artifactId>jstl-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- JSTL 结束  -->
    
    
            <dependency>
                <!--  cglib  依赖        -->
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2.2</version>
            </dependency>
    
    
            <dependency>
                <!-- log4j 依赖  -->
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
    
    
            <dependency>
                <!--   mybatis 依赖      -->
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>3.4.5</version>
            </dependency>
    
        </dependencies>
    
    
    </project>
    
原文地址:https://www.cnblogs.com/javayanglei/p/13547131.html