1.首先把jeesite4的项目导入idea
导入之后在web目录下找到pom 文件,右击添加到maven项目。然后就是下载包了。。。。
2.对在application.yml 文件中配置数据源。MySQL 大家都懂的
然后就是初始化数据库了。下面是文档的内容,提示下4.0的要求是MySQL5.7.11以上的。
(我的是5.6的走set global optimizer_switch='derived_merge=off'; 和grant all privileges on jeesite.* to 'jeesite'@'%' identified by 'jeesite';
这两句的时候报错了。第一句是由于没有那个属性,我设置的是index_merge=off 后面那句没有加,但是也初始化数据库了)
3初始化数据库
1、以MySql为例,配置下SQL模式,否则建表的时候可能会出现问题
打开 my.ini 给 [mysqld] 增加如下配置:
sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
2、 创建用户和授权
set global read_only=0;
set global optimizer_switch='derived_merge=off';
create user 'jeesite'@'%' identified by 'jeesite';
create database jeesite DEFAULT CHARSET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
grant all privileges on jeesite.* to 'jeesite'@'%' identified by 'jeesite';
flush privileges;
3、 打开文件 /src/main/resources/config/application.yml
(v4.0.x:/src/main/resources/config/jeesite.yml
) 配置产品和项目名称及JDBC连接
# 产品或项目名称、软件开发公司名称
productName: JeeSite Demo
companyName: ThinkGem
# 产品版本、版权年份
productVersion: V4.1
copyrightYear: 2018
# 数据库连接
jdbc:
# Mysql 数据库配置
type: mysql
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/jeesite?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username: jeesite
password: jeesite
testSql: SELECT 1
4.用idea运行InitCoreData.java之前需要设置一个参数否则会报异常
4.用idea运行入口类的时候是会出现失败的情况
Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.jeesite.modules.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:692)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
at com.jeesite.modules.Application.main(Application.java:20)
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:169)
at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:393)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:318)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:158)
... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:52542', transport: 'socket'
需要修改pom文件中idea用compile eclipes 是provided
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--idea用compile eclipes 是provided-->
<scope>provided</scope>
<!--<scope>compile</scope>-->
</dependency>