后台启动java
一·后台启动java
./app.sh start
一·后台启动java
./app.sh start
nginx配置java端口访问
xxx就是要访问的后缀
/很重要不然找不到相对路径了。
location /xxx/ {
proxy_pass http://127.0.0.1:8081/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} springboot的配置文件有以下
application.properties
application-dev.properties 开发环境
application-prod.properties 运行环境
application-test.properties 测试环境
在application.properties中配置内容spring.profiles.active=dev
说明是项目默认使用配置文件application-dev.properties
发布项目,打包成jar包之后运行nohup java -jar ***.jar --spring.profiles.active=prod
表示运行使用的是application-prod.properties配置文件
测试环境同理
jdk下载/Linux64位 jdk1.8 jdk-8u161下载
看到在官网下载这个jdk1.8 8u161版本的都要注册账号,百度网盘下载地址:
linux 64 jdk1.8 jdk-8u161-linux-x64.tar.gz百度云盘下载链接:https://pan.baidu.com/s/18IicPYf7W0j-sHBXvfKyyg
windows 64 jdk1.8 8u161百度云盘下载链接:https://pan.baidu.com/s/1eZM0SnpjHY8Wp_H2gkFb7Q
sudo apt-get install openjdk-8-jdk 本地安装Gradle,不然idea导入gradle项目直接报错。
https://www.cnblogs.com/ssl-bl/p/10884873.html
Gradle user home: D:/javalib/.gradle, Build and run using: IntelliJ IDEA; Use Gradle from: 'wrapper' task
bugfree下载,精简的bug管理系统,比禅道简洁。
https://gitee.com/mkk/bugfree3.0.4/attach_files
linux替换字符串aaa->bbb
sed -i "s/aaa/bbb/g" ./src/project.js
安装:yum install subversion
svnserve -d -r /www/svn/repositories --listen-port 8080
killall svnserve
ps -ef|grep svn|grep -v grep
svn://192.168.0.xx:8080
springboot websocket
WebScocketConfig.java
@Configuration
public class WebScocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
````
<!--more-->
WebSocketServer.java@ServerEndpoint("/websocket/{sid}")
@Component
public class WebSocketServer {
private static Logger log = LoggerFactory.getLogger(WebSocketServer.class);
private static final AtomicInteger onlineCount = new AtomicInteger(0);
// concurrent包的线程安全Set,用来存放每个客户端对应的Session对象。
private static CopyOnWriteArraySet<Session> setSession = new CopyOnWriteArraySet<Session>();
/**
* 连接建立成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("sid") String sid) {
setSession.add(session);
int cnt = onlineCount.incrementAndGet(); // 在线数加1
log.info("有连接加入,当前连接数为:{}{}", cnt, sid);
System.out.println("---" +sid);
SendMessage(session, "连接成功");
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose(Session session) {
setSession.remove(session);
int cnt = onlineCount.decrementAndGet();
log.info("有连接关闭,当前连接数为:{}", cnt);
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
@OnMessage
public void onMessage(String message, Session session) {
log.info("来自客户端的消息:{}", message);
SendMessage(session, "收到消息,消息内容:" + message);
}
@OnError
public void onError(Session session, Throwable error) {
log.error("发生错误:{},Session ID: {}", error.getMessage(), session.getId());
error.printStackTrace();
}
/**
* 发送消息,实践表明,每次浏览器刷新,session会发生变化。
*
* @param session
* @param message
*/
public static void SendMessage(Session session, String message) {
try {
session.getBasicRemote().sendText(String.format(message));
} catch (IOException e) {
log.error("发送消息出错:{}", e.getMessage());
e.printStackTrace();
}
}
/**
* 群发消息
*
* @param message
* @throws IOException
*/
public static void BroadCastInfo(String message) throws IOException {
for (Session session : setSession) {
if (session.isOpen()) {
SendMessage(session, message);
}
}
}
/**
* 指定Session发送消息
*
* @param sessionId
* @param message
* @throws IOException
*/
public static void SendMessage(String message, String sessionId) throws IOException {
Session session = null;
for (Session s : setSession) {
if (s.getId().equals(sessionId)) {
session = s;
break;
}
}
if (session != null) {
SendMessage(session, message);
} else {
log.warn("没有找到你指定ID的会话:{}", sessionId);
}
}
}
Maven异常:0.0.1-SNAPSHOT: Could not find artifact
原因是本地仓库缺少了xxx-SNAPSHOT, 原来是忘记了将父工程打包到本地仓库 ,运行聚合工程前记得先将依赖的工程都先Maven install到本地仓库,否则也会出现以上问题。用Maven install 对父工程安装到本地仓库,即可解决该问题。
1.新建项目,打开mybatis-generator-gui生成项目模板
在注解上加上required = false,如下:
@Autowired(required = false)
private UserMapper usermapper; spring boot原来是2016-1018年火起来的,原来以前也是没有这么方便的框架的。原来如此,现在学习这个也不算太慢哈。
一个还不错的学习springboot的网站http://springboot.fun
spring-boot学习地址 19.6k的星星
https://gitee.com/ityouknow/spring-boot-examples
牛逼啊,这个学习地址
文档在这里:https://github.com/ityouknow/spring-boot-examples/
mybatis自动生成
https://github.com/zouzg/mybatis-generator-gui
编译:mvn jfx:jar
cd target/jfx/app/
启动:java -jar mybatis-generator-gui.jar
找一款:
项目进度管理系统
项目管理系统
敏捷开发
https://niaobulashi.com/archives/mybatis-summary.html
mysql设置时区set global time_zone='+8:00';
spring-boot-plus这个开源框架还不错,机智偷懒的框架
https://gitee.com/geekidea/spring-boot-plus
Artifact contains illegal characters 工件包含非法字符
原因是Artifact字段不能用大写,先改小写,点Next,Next步骤后,New Project阶段改回大写即可。