当前位置: 首页 > wzjs >正文

怎么做公司网站需要什么全网营销总结报告

怎么做公司网站需要什么,全网营销总结报告,石家庄 外贸网站建设,杭州大的做网站的公司从socket开始,我们就要开始部署前后端的交互了,所以今天带来一份热度比较高的框架springboot,并教大家如何连接数据库。 框架 先给大家看一下目录结构,因为有些需要调用文件路径: 创建项目: 新版本可以…

从socket开始,我们就要开始部署前后端的交互了,所以今天带来一份热度比较高的框架springboot,并教大家如何连接数据库。

框架

先给大家看一下目录结构,因为有些需要调用文件路径:
请添加图片描述

创建项目:

新版本可以直接创建springboot框架,我这里用的是2023年的版本,更符合大众用户的方式
请添加图片描述
服务器建议改为阿里云的,否则加载会比较慢:https://start.aliyun.com

请添加图片描述
添加这五个依赖项后直接创建就可以了。

添加配置依赖:

pom.xml文件,这里直接复制就可以了,如果有需要可以直接加的:

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>threes</artifactId><version>0.0.1-SNAPSHOT</version><name>threes</name><description>threes</description><properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.6.13</spring-boot.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.4</version></dependency><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.6.0</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>com.example.threes.ThreesApplication</mainClass><skip>true</skip></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build></project>

请添加图片描述
点击同步依赖即可。
application.properties的配置:

spring.datasource.url=jdbc:postgresql://localhost:5432/postgres//这里端口默认为5432,如果你安装时修改了,以你的为准
spring.datasource.username=postgres//默认为postgres,如果修改,还是以你的为准
spring.datasource.password=你的数据库密码
spring.datasource.driver-class-name=org.postgresql.Driver

请添加图片描述
这是我的配置,上面部分是自带的,端口我当时安装时修改了,做完这些,配置就配好了。

主题代码:

FeatureLayer类(这里的命名最好以你要连接的表的名称命名),申明你表里的属性。

package com.example.threes;public class FeatureLayer {private int gid;private String name;private String type;private String beizhu;public int getId(){return gid;}public void setIds(int id) {this.gid = gid;}public String getName(){return name;}public void setName(String name) {this.name = name;}public String getType(){return type;}public void setType(String type) {this.type = type;}public String getBeizhu(){return beizhu;}public void setBeizhu(String type) {this.beizhu = beizhu;}}

FeatureLayerDao接口

package com.example.threes;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.example.threes.FeatureLayer;@Mapper
public interface FeatureLayerDao {List<FeatureLayer> selectAllFeatures() ;}

FeatureLayerService类:

package com.example.threes;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.threes.FeatureLayer;import java.util.List;@Service
public class FeatureLayerService {@Autowiredprivate FeatureLayerDao featlyrDao;public List<FeatureLayer> queryAllFeatures(){return featlyrDao.selectAllFeatures();}}

LayerController类:

package com.example.threes;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;@RestController
@RequestMapping("/threes")
public class LayerController {@Autowiredprivate FeatureLayerService featLyrService;@GetMapping("/query/all")public List<FeatureLayer> queryAllFeatures() {return featLyrService.queryAllFeatures();}
}

ThreesApplication主题类,这部分应该时自己就创建好的,但是要修改一点:

package com.example.threes;import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
@MapperScan("com.example.threes")public class ThreesApplication {public static void main(String[] args) {SpringApplication.run(ThreesApplication.class, args);}}

在resource下创建mapper文件夹,并创建featurelayer.xml:

<?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="com.example.threes.FeatureLayerDao"><select id="selectAllFeatures" resultType="com.example.threes.FeatureLayer">select * from featurelayer</select></mapper>

select*from后的表要给你的数据库中的表的名称要完全一致,大小写都不能错
select id的名称也不能错,这里在FeatureLayerDao接口中
namespace的文件路径也不能错
配置后直接运行就可以了:
请添加图片描述
请添加图片描述
这里的threes替换为你的项目名称,query/all这个路径是你在LayerController 中设定的:
请添加图片描述

报错说明

请添加图片描述
如果这里有问题,说明的xml中的配置有问题请添加图片描述

请添加图片描述
请检查这几部分的代码是否有问题,xml中的名称和路径是否没有差错,这个问题通常是这里有问题。

请添加图片描述
如果出现了这样的错误,通常是找不到对应的数据库:
请添加图片描述
请检查这里的数据库是否能在你的postersql中找的。

有时需要你在idea内部连接数据库,步骤如下:
请添加图片描述
点击右侧的数据库,点击+,数据源为postersql,输入密码和用户,保证端口一致就行,然后刷新框架即可。

尾言

本次的文章以后端为主,之后我会推出Android+spring boot+postersql的综合项目教程的,敬请期待。

http://www.dtcms.com/wzjs/565490.html

相关文章:

  • 郑州小程序开发多少钱关键词优化一年多少钱
  • 福田大型商城网站建设成都游戏开发
  • 网站搜索不到了网页开发环境一般写什么
  • 亚马逊跨境电商个人开店流程昆明搜索引擎的关键词优化
  • pc网站做移动端适配网站安全认证多少钱
  • 深圳企业网站制作流程南昌企业自助建站
  • 做带字头像的网站儿童主题网站的内容建设
  • 啊里云服务器怎么做网站开发区全力做好网站建设
  • wordpress顶图滑动网站seo优化关键词
  • 有链接的网站怎么做网站关键词优化方式
  • 网站建设的关键事项软件定制开发网
  • 多种语言的网站国外域名查询网站
  • 做视频后期的网站做织梦网站之前要新建数据库吗
  • 免费做长图网站网络营销和电子商务区别
  • 单页营销网站怎么做安徽建讯建设工程管理有限公司
  • 全国设计网站建设湖北网页设计师培训
  • 河南省建设工程招标网seo行业
  • 做网站怎么才会被百度收录xampp wordpress服务器
  • 网站流程小说网站建设方案书ppt
  • 网站快照出现两个许昌 网站开发
  • 网站建设华威公司怎么样品牌设计公司宣传文案
  • seo是东莞企业网站排seolinux 建立网站
  • 电脑做系统教学网站免费开源网站
  • 网站建设的大纲wordpress模板怎么制作
  • 网站快速有排名备案信息修改网站名称
  • 网站更改建设方案模板网页设计入门课程
  • app对接网站云系统wordpress
  • 沈阳市建网站宁波正规网络推广多少钱
  • 网站你了解的河南省建设人才教育信息网官网
  • 做网站需要懂程序吗百度热搜广告位多少钱