1. 程式人生 > 其它 >Maven中的Servelet依賴,Mybatis依賴,Mysql依賴,以及兩個xml配置檔案

Maven中的Servelet依賴,Mybatis依賴,Mysql依賴,以及兩個xml配置檔案

技術標籤:mybatismybatismaven

<!--Servlet依賴宣告開始(2個)-->
    <dependency>
      <groupId>jakarta.servlet.jsp</groupId>
      <artifactId>jakarta.servlet.jsp-api</artifactId>
      <version>3.0.0</version>
      <scope>provided</scope>
    </dependency
>
<!--第二個--> <dependency> <groupId>jakarta.servlet</groupId> <artifactId>jakarta.servlet-api</artifactId> <version>5.0.0</version> <scope>provided</scope> </dependency> <!--Servlet依賴宣告完成--> <!--Mybatis依賴宣告開始-->
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.6</version> </dependency> <!--Mybatis依賴宣告完成--> <!--Mysql依賴宣告開始--> <dependency> <groupId>mysql</groupId> <
artifactId
>
mysql-connector-java</artifactId> <version>8.0.23</version> </dependency> <!--Mysql依賴宣告完成--> <!--resources:指定檔案用的將xml和properties檔案都拷貝過去--> <resources> <resource> <directory>src/main/java</directory> <!-- 所在的目錄 --> <includes><!-- 包括目錄下的.properties,xml檔案都會被掃描到--> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <!-- filtering選項false不啟用過濾器,*.properties已經起到過濾作用了--> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> <!--DaoXML檔案編寫開始--> <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.mybatis.example.BlogMapper"> <select id="selectBlog" resultType="Blog"> select * from Blog where id = #{id} </select> </mapper> <!--DaoXML檔案編寫完成--> <!--ResourcesXML檔案編寫開始--> <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- settings 控制mybatis全域性行為--> <settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings> <environments default="online"> <environment id="online"> <transactionManager type="JDBC"/> <dataSource type="POOLED"> <property name="driver" value="com.mysql.cj.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/syfwfl?"/> <property name="username" value="root"/> <property name="password" value="19980605"/> </dataSource> </environment> </environments> <mappers> <mapper resource="org/example/Dao/StudentDao.xml"/> </mappers> </configuration> <!--ResourcesXML檔案編寫完成-->