本文主要是介绍src.main.java.com.taotao.pojo VS com.taotao.pojo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
src.main.java.com.taotao.pojo VS com.taotao.pojo
一,前言:
有些问题看似很简单, 但是有时一下没有想到或没能解决或有的同学没遇到过,就会变得非常的尴尬,但也不要着急,最好的办法就是: 站在巨人的肩膀上.
二,问题
这次在引入实体时,硬是引入不对,总是报错.
命名实体位置是在: com.taotao.pojo 中, 但是引入包是却出现src.main.java.com.taotao.pojo
三,详情
1,分析情况,这是因为引入包的方式不对,一, pom中可能没有引入自己; 二, pom可能实体的依赖不对.
2,解决方案:
在 pom 中, 必须引入自己的同时,也要有对其他包的依赖.
3,原理:
Mapper 依赖 pojo
Service 要依赖 mapper
Web 要依赖 Service
4,具体的代码:
1,taotao-manager-pojo:
<projectxmlns="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.0http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId></dependency></dependencies><parent><groupId>com.taotao</groupId><artifactId>taotao-manager</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-manager-pojo</artifactId>
</project>
2,taotao-manager-mapper
<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><parent><groupId>com.taotao</groupId><artifactId>taotao-manager</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-manager-mapper</artifactId><!-- 依赖管理 --><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-pojo</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Mybatis --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId></dependency><dependency><groupId>com.github.miemiedev</groupId><artifactId>mybatis-paginator</artifactId></dependency><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId></dependency><!-- MySql --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!-- 连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId></dependency></dependencies><!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources></build>
</project>
3,taotao-manager-service
<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><parent><groupId>com.taotao</groupId><artifactId>taotao-manager</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-manager-service</artifactId><!-- 依赖管理 --><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-mapper</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId></dependency></dependencies>
</project>
4,taotao-mapper-web
<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><parent><groupId>com.taotao</groupId><artifactId>taotao-manager</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-manager-web</artifactId><packaging>war</packaging><!-- 依赖管理 --><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-service</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- JSP相关 --><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jsp-api</artifactId><scope>provided</scope></dependency><!-- 文件上传组件 --><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId></dependency><!--swagger--><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.5.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.5.0</version></dependency></dependencies>
</project>
四,小结:
山不在高,有仙则灵;水不在深,有龙则灵. 问题或bug 不一定要非常的困难,高级, 只要是我们成长中遇到的,我们花时间了,最后通过自己也解决了,这就是一个成长.
原和读者您互相交流,共同学习,共同进步.
这篇关于src.main.java.com.taotao.pojo VS com.taotao.pojo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!