时间:2021-07-01 10:21:17 帮助过:3人阅读
中间遇到了问题“-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.”,可以在这里解决。
加载完dependence之后,按Andy的Mybatis使用generator自动生成映射配置文件信息交待生成配置文件。其中正确生成了BxxxxxLxxxx.java,BxxxxxLxxxxMapper.java 以及BxxxxxLxxxxMapper.xml,分别放在\src\main\java\com\xxxxx\xxx\domain,src\main\java\com\xxxxx\xxx\mapper以及src\main\java\com\xxxxx\xxx\mapper\sqlmaps目录下。
按照步骤提示继续,针对即将新引入的jar包,更改pom.xml文件
<!-- spring add by Steven --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.1.1.RELEASE</version> <scope>test</scope> </dependency> <!-- mybatis add by Steven --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.1.0</version> </dependency> <!--mybatis spring add by Steven --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.1.1</version> </dependency> <!--log4j add by Steven --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!-- struts2 add by Steven --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.16.3</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>2.3.16.3</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.16.3</version> </dependency> <!-- Gson add by Steven --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.1</version> </dependency> <!-- c3p0 add by Steven --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5</version> </dependency> <!-- aspectjweaver add by Steven --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.8</version> </dependency> <!-- cglib add by Steven --> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.2.2</version> </dependency> ... <resources> <resource> <directory>src/main/resource</directory> <includes> <include>*.xml</include> <include>*.properties</include> </includes> </resource> </resources>以及需要在build节点里加入以下resources引用,以帮助Maven加载需要的struts和myBatisConfig的配置文件。
为Eclipse上的Maven project添加SpringMVC和Mybatis以实现数据库package的调用
标签: