eclipse 初始化java工具_Eclipse初始化时的配置及框架相关

本文介绍如何在Eclipse中进行环境配置以支持UTF-8编码,并详细讲解了SpringMVC、Spring和Mybatis组成的SSM框架的具体配置步骤及所需版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

eclipse

第一次打开eclipse要进行如下步骤

新建一个web服务器

首选项/web/JSP Files -> 修改jsp文件为utf-8

首选项/工作空间 -> 全局修改编码格式为utf-8

Maven/User Settings -> 修改settings.xml文件为自己改好的文件

常规/外观/颜色和字体/基本/文本字体 -> 字体修改为中欧字符,使字体正常显示

配置任务 首选项/java/编译器/任务标记 新增任务标记

SSM

在SSM框架中要进行繁杂的配置,以下配置已被验证为可执行,只需要修改相关参数即可,版本如下:

1

2

SpringMVC

4.0.0.RELEASE

Spring

4.0.0.RELEASE

Mybatis

3.2.8

C3P0连接池

0.9.2

MYSQL驱动

5.1.37

applicationContext.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

value="jdbc:mysql://localhost:3306/crowdfunding-v?characterEncoding=utf8"/>

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

expression="(execution(* com.ssmdemo.service.*.*(..)))"/>

springmvc-servlet.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

base-package="com.ifance.*" use-default-filters="false">

expression="org.springframework.stereotype.Controller" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">

class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">

application/json;charset=UTF-8

class="org.springframework.web.multipart.commons.CommonsMultipartResolver"

p:defaultEncoding="UTF-8">

web.xml

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Archetype Created Web Application

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

encodingFilter

/*

contextConfigLocation

classpath:spring/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:spring/springmvc-servlet.xml

1

springmvc

/

mybatis-config.xml

/p>

PUBLIC "-//mybatis.org//DTD//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

依赖

javax.servlet

servlet-api

2.5

javax.servlet.jsp

jsp-api

2.1.3-b06

org.springframework

spring-core

4.0.0.RELEASE

org.springframework

spring-context

4.0.0.RELEASE

org.springframework

spring-jdbc

4.0.0.RELEASE

org.springframework

spring-orm

4.0.0.RELEASE

org.springframework

spring-web

4.0.0.RELEASE

org.springframework

spring-webmvc

4.0.0.RELEASE

com.mchange

c3p0

0.9.2

cglib

cglib

2.2

org.aspectj

aspectjweaver

1.6.8

org.mybatis

mybatis

3.2.8

org.mybatis

mybatis-spring

1.2.2

log4j

log4j

1.2.17

org.slf4j

slf4j-api

1.7.7

org.slf4j

slf4j-log4j12

1.7.7

mysql

mysql-connector-java

5.1.37

jstl

jstl

1.2

net.sf.ehcache

ehcache

1.6.2

org.quartz-scheduler

quartz

1.8.5

org.springframework

spring-context-support

4.0.0.RELEASE

commons-collections

commons-collections

3.1

org.codehaus.jackson

jackson-mapper-asl

1.9.2

org.apache.poi

poi

3.9

org.jfree

jfreechart

1.0.19

commons-fileupload

commons-fileupload

1.3.1

org.freemarker

freemarker

2.3.19

org.activiti

activiti-engine

5.15.1

org.activiti

activiti-spring

5.15.1

org.apache.commons

commons-email

1.3.1

org.activiti

activiti-explorer

5.15.1

groovy-all

org.codehaus.groovy

org.projectlombok

lombok

1.18.8

provided

SpringBoot初始化项目命令

mvn archetype:generate -DinteractiveMode=false -DgroupId=com.lou.springboot -DartifactId=springboot-demo -Dversion=0.0.1-SNAPSHOT

SpringBoot的配置文件

# 这个配置一般正式发布时不配置

#server.context-path=/Example

############################################################

#

# devtools 热部署相关配置

#

############################################################

#关闭缓存, 即时刷新

#spring.freemarker.cache=false

spring.thymeleaf.cache=true

#热部署生效

spring.devtools.restart.enabled=true

#设置重启的目录,添加那个目录的文件需要restart

spring.devtools.restart.additional-paths=src/main/java

# 为mybatis设置,生产环境可删除

#restart.include.mapper=/mapper-[\\w-\\.]+jar

#restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar

#排除那个目录的文件不需要restart

spring.devtools.restart.exclude=static/**,public/**

#classpath目录下的WEB-INF文件夹内容修改不重启

spring.devtools.restart.exclude=WEB-INF/**

############################################################

#

# REDIS 配置

#

############################################################

# Redis数据库索引(默认为0)

spring.redis.database=1

# Redis服务器地址

spring.redis.host=192.168.1.191

# Redis服务器连接端口

spring.redis.port=6379

# Redis服务器连接密码(默认为空)

spring.redis.password=

# 连接池最大连接数(使用负值表示没有限制)

spring.redis.pool.max-active=1000

# 连接池最大阻塞等待时间(使用负值表示没有限制)

spring.redis.pool.max-wait=-1

# 连接池中的最大空闲连接

spring.redis.pool.max-idle=10

# 连接池中的最小空闲连接

spring.redis.pool.min-idle=2

# 连接超时时间(毫秒)

spring.redis.timeout=0

############################################################

#

# 配置数据源相关 使用阿里巴巴的 druid 数据源

#

############################################################

spring.datasource.url=jdbc:mysql://localhost:3306/guns

spring.datasource.username=root

spring.datasource.password=root

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.druid.initial-size=1

spring.datasource.druid.min-idle=1

spring.datasource.druid.max-active=20

spring.datasource.druid.test-on-borrow=true

spring.datasource.druid.stat-view-servlet.allow=true

############################################################

#

# mybatis 配置

#

############################################################

# mybatis 配置

mybatis.type-aliases-package=com.example.pojo

mybatis.mapper-locations=classpath:mapper/*.xml

# 通用 Mapper 配置

mapper.mappers=com.example.utils.MyMapper

mapper.not-empty=false

mapper.identity=MYSQL

# 分页插件配置

pagehelper.helperDialect=mysql

pagehelper.reasonable=true

pagehelper.supportMethodsArguments=true

pagehelper.params=count=countSql

############################################################

#

# 配置i18n 资源文件,供thymeleaf 读取

#

############################################################

spring.messages.basename=i18n/messages

# 缓存时间10分钟

spring.messages.cache-seconds=3600

spring.messages.encoding=UTF-8

#设定静态文件路径,js,css等

spring.mvc.static-path-pattern=/static/**

############################################################

#

# freemarker 静态资源配置

#

############################################################

#设定ftl文件路径

spring.freemarker.template-loader-path=classpath:/templates

# 关闭缓存, 即时刷新, 上线生产环境需要改为true

spring.freemarker.cache=false

spring.freemarker.charset=UTF-8

spring.freemarker.check-template-location=true

spring.freemarker.content-type=text/html

spring.freemarker.expose-request-attributes=true

spring.freemarker.expose-session-attributes=true

spring.freemarker.request-context-attribute=request

spring.freemarker.suffix=.ftl

############################################################

#

# thymeleaf 静态资源配置

#

############################################################

spring.thymeleaf.prefix=classpath:/templates/

spring.thymeleaf.suffix=.html

spring.thymeleaf.mode=HTML5

spring.thymeleaf.encoding=UTF-8

spring.thymeleaf.content-type=text/html

# 关闭缓存, 即时刷新, 上线生产环境需要改为true

spring.thymeleaf.cache=false

############################################################

#

# Server 服务端相关配置

#

############################################################

# 配置api端口号

server.port=8080

# 配置context-path, 一般来说这个配置在正式发布的时候不配置

#server.context-path=/IMooc

# 错误页,指定发生错误时,跳转的URL --> BasicErrorController

#server.error.path=/error

# session最大超时时间(分钟),默认为30分钟

server.session-timeout=60

# 该服务绑定IP地址,启动服务器时如本机不是该IP地址则抛出异常启动失败,

# 只有特殊需求的情况下才配置, 具体根据各自的业务来设置

#server.address=192.168.1.2

############################################################

# Server - tomcat 相关常用配置

############################################################

# tomcat最大线程数, 默认为200

#server.tomcat.max-threads=250

# tomcat的URI编码

server.tomcat.uri-encoding=UTF-8

# 存放Tomcat的日志、Dump等文件的临时文件夹,默认为系统的tmp文件夹

#(如:C:\Users\Shanhy\AppData\Local\Temp)

#server.tomcat.basedir=H:/springboot-tomcat-tmp

# 打开Tomcat的Access日志,并可以设置日志格式的方法:

#server.tomcat.access-log-enabled=true

#server.tomcat.access-log-pattern=

# accesslog目录,默认在basedir/logs

#server.tomcat.accesslog.directory=

# 日志文件目录

#logging.path=H:/springboot-tomcat-tmp

# 日志文件名称,默认为spring.log

#logging.file=myapp.log

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值