当前位置:网站首页>ssm访问数据库数据报错
ssm访问数据库数据报错
2022-08-02 12:16:00 【CSDN问答】
ssm框架tomcat服务器访问数据库数据报错,猜测是数据库连接的问题又不敢确认,有遇到过这种问题的吗
服务器的错误信息如下
tomcat日志信息
controller层的类
package com.duing.controller;import com.duing.service.FilmService;import com.duing.vo.FilmVo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;@Controllerpublic class FilmController { @Autowired private FilmService filmService; @RequestMapping("/filmList") @ResponseBody public List
selectAll(){ List
filmVos = filmService.selectAll();
return filmVos; }}
dao层的接口信息
package com.duing.dao;import com.duing.entity.Film;import java.util.List;public interface FilmDao { List
getList
();}
映射类信息
package com.duing.entity;import java.io.Serializable;import java.util.Date;// 实体类 跟数据库的表映射public class Film implements Serializable { private static final long serialVersionUID = -4427069375523038931L; private long id; private String film_id; private String name; private String director; private String player; private String type; private String country; private int length; private String synopsis; private Date play_time; private String img_path; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getFilm_id() { return film_id; } public void setFilm_id(String film_id) { this.film_id = film_id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getPlayer() { return player; } public void setPlayer(String player) { this.player = player; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public String getSynopsis() { return synopsis; } public void setSynopsis(String synopsis) { this.synopsis = synopsis; } public Date getPlay_time() { return play_time; } public void setPlay_time(Date play_time) { this.play_time = play_time; } public String getImg_path() { return img_path; } public void setImg_path(String img_path) { this.img_path = img_path; }}
service层接口
package com.duing.service;import com.duing.vo.FilmVo;import java.util.List;public interface FilmService { List
selectAll
();}
service层类
package com.duing.service.impl;import com.duing.dao.FilmDao;import com.duing.entity.Film;import com.duing.service.FilmService;import com.duing.vo.FilmVo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.ArrayList;import java.util.List;@Servicepublic class FilmServiceimpl implements FilmService { @Autowired private FilmDao filmDao; @Override public List
selectAll
() { List
films = filmDao.getList(); System.out.println(
"数据库影片数量"+films.size()); List
result=
new
ArrayList<>();
for (Film film : films) { FilmVo vo=
new
FilmVo(); vo.setFilmId(film.getFilm_id()); vo.setName(film.getName()); vo.setDirector(film.getDirector()); vo.setImgpath(film.getImg_path()); result.add(vo); }
return result; }}
视图层vo
package com.duing.vo;// 视图层对象 用来展示给用户使用public class FilmVo { private String filmId; private String name; private String director; private String imgpath; public String getFilmId() { return filmId; } public void setFilmId(String filmId) { this.filmId = filmId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getImgpath() { return imgpath; } public void setImgpath(String imgpath) { this.imgpath = imgpath; }}
mapper配置信息
package com.duing.vo;// 视图层对象 用来展示给用户使用public class FilmVo { private String filmId; private String name; private String director; private String imgpath; public String getFilmId() { return filmId; } public void setFilmId(String filmId) { this.filmId = filmId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getImgpath() { return imgpath; } public void setImgpath(String imgpath) { this.imgpath = imgpath; }}
mybtis配置信息
configuration PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <mappers> <package name="com.duing.dao"/>
mappers>
configuration>
spring配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.service"/>
<context:property-placeholder location="classpath:druid.properties"/>
<bean id="datasource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/>
bean>
<bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="datasource"/> <property name="configLocation" value="classpath:/mybatis.xml"/>
<property name="mapperLocations" value="classpath:mappers/*.xml"/>
bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="factory"/> <property name="basePackage" value="com.duing.dao"/>
bean>
beans>
springmvc配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/>
bean>
<mvc:annotation-driven/> <context:annotation-config/>
beans>
druid.properties信息
jdbc.url=jdbc://mysql://localhost:3306/ssm?characterEncoding=utf8jdbc.username=rootjdbc.password=root
pom.xml信息
<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>com.duing
groupId> <artifactId>ssm-duing-ticket
artifactId> <version>1.0-SNAPSHOT
version> <packaging>war
packaging> <name>ssm-duing-ticket Maven Webapp
name>
<url>http://www.example.com
url> <properties> <project.build.sourceEncoding>UTF-8
project.build.sourceEncoding> <maven.compiler.source>1.7
maven.compiler.source> <maven.compiler.target>1.7
maven.compiler.target>
properties> <dependencies> <dependency> <groupId>junit
groupId> <artifactId>junit
artifactId> <version>4.11
version> <scope>test
scope>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-context
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-tx
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-webmvc
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.mybatis
groupId> <artifactId>mybatis
artifactId> <version>3.5.6
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-jdbc
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.mybatis
groupId> <artifactId>mybatis-spring
artifactId> <version>2.0.6
version>
dependency>
<dependency> <groupId>mysql
groupId> <artifactId>mysql-connector-java
artifactId> <version>8.0.22
version>
dependency>
<dependency> <groupId>com.alibaba
groupId> <artifactId>druid
artifactId> <version>1.2.4
version>
dependency>
<dependency> <groupId>javax.servlet
groupId> <artifactId>javax.servlet-api
artifactId> <version>4.0.1
version> <scope>provided
scope>
dependency>
<dependency> <groupId>javax.servlet.jsp
groupId> <artifactId>jsp-api
artifactId> <version>2.2
version> <scope>provided
scope>
dependency>
<dependency> <groupId>com.fasterxml.jackson.core
groupId> <artifactId>jackson-core
artifactId> <version>2.12.1
version>
dependency> <dependency> <groupId>com.fasterxml.jackson.core
groupId> <artifactId>jackson-databind
artifactId> <version>2.12.1
version>
dependency>
dependencies> <build> <finalName>ssm-duing-ticket
finalName> <pluginManagement>
<plugins> <plugin> <artifactId>maven-clean-plugin
artifactId> <version>3.1.0
version>
plugin>
<plugin> <artifactId>maven-resources-plugin
artifactId> <version>3.0.2
version>
plugin> <plugin> <artifactId>maven-compiler-plugin
artifactId> <version>3.8.0
version>
plugin> <plugin> <artifactId>maven-surefire-plugin
artifactId> <version>2.22.1
version>
plugin> <plugin> <artifactId>maven-war-plugin
artifactId> <version>3.2.2
version>
plugin> <plugin> <artifactId>maven-install-plugin
artifactId> <version>2.5.2
version>
plugin> <plugin> <artifactId>maven-deploy-plugin
artifactId> <version>2.8.2
version>
plugin>
plugins>
pluginManagement>
build>
project>
包结构
边栏推荐
- openresty 性能优化
- Solve the problem of Chinese garbled characters in exporting excel file names
- DTG-SSOD:最新半监督检测框架,Dense Teacher(附论文下载)
- When not to use () instead of Void in Swift
- Lexicon 27 - Remove Elements - Simple Questions
- 使用kubesphere图形界面创建一个应用操作流程
- An example of type3 voltage loop compensator taking Boost as an example
- 分布式限流利器,手撕&redisson实现
- The use of QListView
- Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单。
猜你喜欢
Process finished with exit code 1
CCF paper conference IEEE how to query all articles of a conference journal
Speed up your programs with bitwise operations
Process finished with exit code 1
numpy&pands 中的unique
QAbstractScrollArea、QScrollArea
Problem solving in the process of using mosquitto
用位运算为你的程序加速
使用kubesphere图形界面创建一个应用操作流程
Likou 209 - String with the Minimum Length - Sliding Window Method
随机推荐
手撸架构,MongDB 面试50问
网站自动翻译-网站批量自动翻译-网站免费翻译导出
An example of type3 voltage loop compensator taking Boost as an example
unique in numpy & pandas
How to connect TDengine through DBeaver?
MD5详解(校验文件完整性)
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
故障分析 | 一条 SELECT 语句跑崩了 MySQL ,怎么回事?
npm install报错npm ERR Could not resolve dependency npm ERR peer
simulink PID auto-tuning
以Boost为例的type3电压环补偿器实例
SQL function TRIM
技术分享| 融合调度系统中的电子围栏功能说明
Hand rolled architecture, 41 Redis interview asked
手撸架构,网络 面试36问
7种最常用数据分析思维,解决95%的分析难题
手撸架构,Redis面试41问
面积曲线AUC(area under curve)
数据湖(二):什么是Hudi
Swift中什么时候不能用 () 代替 Void 来使用