IDEA 使用记录备忘

  1. Mac下IDEA使用SVN报CommandLine错误的解决方法:

Mac OS 升级系统后 Idea 集成的SVN使用报错:The subversion command line tools are no longer provided by Xcode. | HY-Blogs

2.JDK16加载lombok报错,通过升级版本即可解决

通过升级lombok版本解决了此问题:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.20</version>
</dependency> 

3.报错:程序包org.springframework.web.bind.annotation不存在

解决办法:File>Settings>Build, Execution, Deployment>Build Tools>Maven>Runner>Delegate IDE.... 这个选项勾选,亲测有效

4.做测试的时候,注意要加上和主类一致的包名:

package com.haha.law;
@SpringBootTest
public class lawtest {
    @Autowired(required = false)
    RoleService roleService;
    @Test
    void TestRole(){
        Map<String, Object> sgp =  roleService.getListPager(1,10);
        System.out.println(sgp);
    }
}

5.pom.xml中报插件错误,且无运行配置时:

<artifactId>spring-boot-maven-plugin</artifactId>

解决方案: 加上一个版本即可。

<version>2.5.3</version>

6.部署项目:

  第一种:jar包(官方推荐)
jar包方式启动,也就是使用spring boot内置的tomcat运行。服务器上面只要你配置了jdk1.8及以上,就ok。不需要外置tomcat
1.先将项目在IDEA中打成jar包

2.在服务器上安装Nginx,配置nginx.conf


    server {
        listen       8080;  //nginx不和tomcat冲突。
        server_name  mysite.domain.com;

         location / {
            root  C:\site\mysite.domain.com;
            index  index.html index.htm;
        }
3.java -jar mysite.jar

6.1 通过IDEA分解部署到外置tomcat.

  1.在IDEA->文件->项目结构->工件->+ Web应用程序-展开型-基于模块,自定义输出目录。

  2.IDEA->构建->构建工件->选择刚建的->构建。此时第一步目录中会有一些文件。

  3.将目录中的文件右键->部署。(部署不起作用一般是FTP没设置好。)

7.项目运行后自动打开浏览器功能:

@Component
public class BrowserRunner implements CommandLineRunner {

    @Value("${brower.autoopenurl}")
    private String openUrl;

    @Value("${brower.autoopen}")
    private boolean isOpen;

    @Override
    public void run(String... args) {
        if (isOpen) {
            System.out.println("自动加载指定的页面");
            try {
                Runtime.getRuntime().exec("cmd /c start " + openUrl);  // 可以指定自己的路径
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("浏览器打开页面异常");
            }
        }
    }
}

8.SpringBootIDE如果一启动就报错:Git未安装,则重新安装 Command Line Tools For XCode ..即可。/新增加:这种情况在系统版本更新时出现,更新一个Git即可解决: brew install git

9:SpringBoot 缓存机制因切面原因不支持类内方法缓存。解决办法是:在类内定义:

@Autowired CategoryService cs;//

调用时用cs.xxx(); 即可解决。

10. 发布时打jar包已包含了tomcat,打war包即之前的方式,maven直接install后,会有一个错误:

 webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode

解决方案:在POM.xml中加

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.3.1</version>
</plugin>
 

Maven打包web项目报错:webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update)_itmkyuan的博客-CSDN博客

11.SpringBoot集成 Shiro时POM中注意:

如果报错:bean named 'shiroFilterFactoryBean' that could not be found。如果使用了shiro starter依赖,则修改了pom的依赖,由shiro-spring-boot-web-starter改为shiro-spring即可解决。 

12.springboot 依赖报红解决办法:

<repositories>
    <repository>
        <id>aliyun-repos</id>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>aliyun-plugin</id>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

位置:build - > maven -> runner VM:

  1. ssl安全性的校验,需要核验,需要跳过这项规则
    则在setting该位置中加入这行代码
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

13.用IDEA构建一个SSM项目,POM内容如下:

 

<packaging>war</packaging> //加这个可以解决运行后项目自动停止的问题
<dependencies>
    <!--Spring 核心类-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.2.12.RELEASE</version>
    </dependency>
    <!--Spring MVC-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.2.12.RELEASE</version>
    </dependency>
    <!-- servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!--JSP-->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<!--构建-->
<build>
    <!--设置插件-->
    <plugins>
        <!--具体的插件配置-->
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version> 报红这里加上版本号解决问题
                        <configuration>
                            <port>8080</port>
                            <path>/</path>
                        </configuration>
                    </plugin>
    </plugins>
</build>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值