《青橙商城》day01避坑指南
1.persistence-api报红
问题:
在模块qingcheng_pojo下的pom.xml中,报红
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>//报红字
<artifactId>persistence-api</artifactId>//报红字
<version>1.0</version>//报红字
</dependency>
</dependencies>
原因:
不能从中央仓库下载 jar包,出错了。
解决办法:
在maven安装路径下:maven/conf/setting.xml中添加:
<!-- 国内maven镜像 -->
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
还可以:
在模块qingcheng_parent下的pom.xml中,添加镜像依赖:
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
2.pagehelper报红
问题:
在模块qingcheng_common_service下applicationContext-dao.xml中,以下代码报红:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="plugins">
<array> //报红字 //报红字
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">//报红字
<value>
dialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
原因:
在模块qingcheng_common_service下的pom.xml中,缺少pagehelper的依赖。
解决办法:
在模块qingcheng_common_service下的pom.xml中,添加依赖,代码:
<dependencies>
//省略其它依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.4</version>
</dependency>
</dependencies>
为什么是4.1.4的版本?因为5.*的版本比mybaitis的jar包版本相差过大,高了。
注意,还有一步:
在模块qingcheng_parent下的pom.xml中,虽然没添加依赖,但是锁定了pagehelper版本。这里要把版本号改成4.1.4,和刚刚的版本一致:
还有一些细节,你是否做到了?
1、记得SQLyog导入6个sql脚本进数据库
2、zookeeper使用前,将conf目录下的zoo_sample.cfg改名为zoo.cfg
3、启动 tomcat 项目前的顺序:
1---检查有无正在运行的 tomcat 并关闭,因为占端口号
2---启动zookeeper/bin目录下的zkServer.cmd
3---如果代码有更改,就使用生命周期install一下
4---最后依次启动tomcat7:run
4、启动工程后,浏览器测试 : 记得加 .do
http://localhost:9101/brand/findAll.do

浙公网安备 33010602011771号