搜索一番,是由于IDEA版本导致的Lombok失效,不过这个问题后来解决了。
所以,我们只需要更新lombok版本,使用1.18.14及之后的版本即可:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.14</version>
<scope>provided</scope>
</dependency>
IDEA 插件 正常安装,需要升级 Lombok 版本
参考 链接: https://blog.csdn.net/chinaherolts2008/article/details/118711313
1.首先先准备好 jdk1.7 linux 和tomcat7的安装包(这里使用的是jdk linux 32位的 文章底部奉上需要的安装包)
2. 将包文件拷贝到用户目录 我这里是 /home/rain/
3.解压 jdk文件 和tomcat文件
tar -zxvf a*****
4.打开 vim /etc/profile 在最后一行插入下面的数据
#set java environment
JAVA_HOME=/home/rain/jdk1.7.0_80
JRE_HOME=/home/rain/jdk1.7.0_80/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
注意需要将上面的/home/rain/** 目录替换成自己jdk的目录
5. 输入 source /etc/profile 刷新环境变量后 输入 java -version 查看控制台
如果显示当前数据表示jdk已经完成安装了
6.进入解压后的tomcat 目录中 找到bin目录并进入
直接在命令行输入 ./catalina.sh run 如果出现以下的信息表示启动完成了,直接通过浏览器访问 Http:xxx.xxx.xxx.xxx:8080/
外面的 html 文件 index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>fullScreen</title>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<iframe allowfullscreen src="iframe.html" frameborder="0" style="width: 500px;height: 500px;background:#aaa"></iframe>
</body>
</html>
里面嵌套的 iframe.html 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<h1>iframe</h1>
<button id="button">全屏</button>
<script>
// 判断是否允许全屏
var fullscreenEnabled =
document.fullscreenEnabled ||
document.mozFullScreenEnabled ||
document.webkitFullscreenEnabled ||
document.msFullscreenEnabled;
// 全屏
function launchFullscreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullScreen();
}
}
// 退出全屏
function exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
var btn = document.querySelector('#button');
if (fullscreenEnabled) {
btn.addEventListener('click', function () {
var fullscreenElement =
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement;
if (fullscreenElement) {
exitFullscreen();
btn.innerHTML = '全屏';
} else {
launchFullscreen(document.documentElement);
btn.innerHTML = '退出全屏';
}
}, false);
}
// 监听全屏事件
document.addEventListener('webkitfullscreenchange', function fullscreenChange() {
if (document.fullscreenEnabled ||
document.webkitIsFullScreen ||
document.mozFullScreen ||
document.msFullscreenElement) {
console.log('enter fullscreen');
} else {
console.log('exit fullscreen');
}
}, false);
</script>
</body>
</html>
$("#roomNo").change(function() {
if ($("#roomNo").get(0).checked) {
alert("选中");
}else {
alert("取消");
$("#roomNo_span").remove();
}
});
本地有一个工程使用的是Eclipse maven构建的,由于需要将其移动到IDEA中开发,继而将导入步骤做出一下记录,方便查阅
第一步 打开IDEA checkout 源文件
本地需要先安装SVN工具 command line dient tools 必须安装 -> 传送门
选中一个目录 提取到该目录下面 (一般选择第二个) E:\idea_project\chouchou
直接导入Eclipse 模型 (maven 配置后面会自动检测) 一直下一步 下一步 是
如果导入的工程目录文件夹错误 ,
将工程导入到IDEA后 系统会在右下角提示这是一个maven 工程(不要急着构建maven工程 先将lib下面的 包引入到工程中) put into WEB-INF/lib 下面
点击右侧 导航条 的maven (此步骤可以省略)
打开项目结构 (导航栏上方按钮)
修改 SDK 我用的是jdk 1.7 及 非maven jar 包 导入
点击 jars 或目录
添加 Artifacts
查看刚才加入 的外部lib 有没有复制到 WEB-INF/lib/ 下面 如果没用 在右侧加入
打开设置 配置本地的maven
配置一个tomcat 就可以运行启动了
注意上述 完成 需要用 war exploded 来调试 文件发布 ,不要用war 包发布 ,修改 jsp之类的静态文件 不会自动更新
如果导入的工程文件 结构混乱
按下列步骤操作:
1. 关闭IDEA,
2.然后删除项目文件夹下的.idea文件夹
3.重新用IDEA工具打开项目
如果导入的工程 出现找不到配置文件 (resource)
项目的pom 文件需要 引入以下maven 配置支撑
<build>
<finalName>high-tech</finalName>
<plugins>
<!-- 更改maven默认的打包目录 -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${basedir}/src/main/webapp</webappDirectory>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
<configuration>
<includeScope>system</includeScope>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
一 、官网下载JDK
1.进入Oracle 官网下载 jdk http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
二、解压配置
将JDK目录解压到
tar -zxvf jdk-7u80-linux-i586.tar.gz
mv jdk-7u80-linux-i586.tar.gz/ /usr/lib/jvm
或者 tar -zxvf jdk-7u60-linux-x64.gz -C /usr/lib/jvm
三、配置环境变量
vim ~/.bashrc
文章末尾
#set oracle jdk environment
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_60 ## 这里要注意目录要换成自己解压的jdk 目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
刷新环境变量
source ~/.bashrc
测试
java -version
下载配置tomcat7
官网下载tomcat https://tomcat.apache.org/download-70.cgi
解压 cd /usr/local/tomcat/ bin/ 目录下面路径可以直接执行
关于 Server.XML 配置
https://www.cnblogs.com/kismetv/p/7228274.html
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- spring的配置文件 一般写入数据源 事务控制 mybatis扫描 mapper 文件中 IOC控制器中 -->
<!-- 扫描service 层下面所有的 @Server 加入ICO容器中 -->
<context:annotation-config />
<context:component-scan base-package="com.rain.service" />
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="url" value="jdbc:mysql://localhost:3306/power?characterEncoding=UTF-8" />
<property name="username" value="root" />
<property name="password" value="root" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="3" />
<property name="minIdle" value="3" />
<property name="maxActive" value="20" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="validationQuery" value="SELECT 1" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
</bean>
<!-- mybatis 和spring 进行整合 -->
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="typeAliasesPackage" value="com.rain.pojo" />
<property name="dataSource" ref="dataSource"/>
<!-- 指定mybatis mapper文件的地址 -->
<property name="mapperLocations" value="classpath:com/rain/mapper/*.xml"/>
<property name="plugins">
<array>
<!-- pagehelper -->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<!--使用下面的pagehelper方式配置参数,一行配置一个 -->
<value>
</value>
</property>
</bean>
</array>
</property>
</bean>
<!-- 配置扫描器 将 mybatis 接口的实现加入 ioc 容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 扫描 该包路径下 所有 DAO接口的实现 加入 到 IOC容器中 -->
<property name="basePackage" value="com.rain.mapper"/>
</bean>
<!-- 配置spring的PlatformTransactionManager,名字为默认值 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 开启事务控制的注解支持 比较多的使用 xml配置形式的事务-->
<aop:config>
<!-- 切入点表达式 -->
<aop:pointcut expression="execution(* com.rain.service..*(..))" id="txPoint"/>
<!-- 事务增强 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/>
</aop:config>
<!-- 配置事务增强 如何切入 -->
<tx:advice id="txAdvice">
<tx:attributes>
<!-- 所有方法都是事务方法 -->
<tx:method name="*" />
<!-- 以get开始的所有方法 -->
<tx:method name="get*" read-only="true"/>
</tx:attributes>
<!-- spring配置文件核心点 数据源 与mybatis 整合 -->
</tx:advice>
</beans>
环境 :Tomcat 7 JavaEE版本 选择了 Servert 3.1 也就是JavaEE 3.1
其实遇上这个问题主要是建立Java Web工程时,没有仔细观察
而实际上
我们可以来看看Tomcat最近几个版本分别支持的JavaEE规范。
------------------------
Tomcat 6: Servlet 2.5、JSP 2.1、EL 2.1
Tomcat7: Servlet 3.0、JSP 2.2、EL 2.2
Tomcat8: Servlet 3.1、JSP 2.3、EL 3.0
------------------------
继而会出现运行不支持的问题!
近期项目需要用到底层通讯的继而采用MQTT
之前已经搭建过MQTT 并且用websocket技术进行连接了 http://www.rainfly.cn/?post=285
在EMQTT官网下载 Windows 10 x64 位的包 后解压到目录下面 然后 运行起来
用本地通讯猫测试工具 检查是否开启正常!
在Maven中添加上相关依赖的包
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.0.2</version>
</dependency>
实现代码:打包下载 -> https://github.com/Rain-Fly/MQTT
三种方法
第一种:使用set方法注入
public class User {
private String name;
public void setName(String name) {
this.name = name;
}
}
User user = new User();
user.setName("abcd");
第二种 有参数构造注入
public class User {
private String name;
public User(String name) {
this.name = name;
}
}
第三种使用接口注入
interface Dao {
public void setName(String name);
}
public class DaoImpl implements Dao {
private String name;
public void setName(String name) {
this.name=name;
}
}