【springboot】 springboot工程搭建及常见问题

Spring-Boot--日志操作【全局异常捕获消息处理☞日志控制台输出+日志文件记录】

https://blog.csdn.net/liuweixiao520/article/details/78900779

 

Spring boot Mybatis 整合(完整版)

https://blog.csdn.net/winter_chen001/article/details/77249029

 

问题:

springboot版本问题 Cannot load configuration class: org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration

http://3ms.huawei.com/km/blogs/details/5457353

当你看到这个异常时,你试一试把springboot版本升级

Cannot load configuration class: org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration

	
		
			
				
				org.springframework.boot
				spring-boot-dependencies
				1.4.2.RELEASE
				pom
				 import
			
		
	

 

使用mybatis报错The error occurred while setting parameters的终极解决办法

1.检查sql语句,最好的检查方法就是将sql语句复制到查询器中执行一遍。

2.检查Mapper接口,参数名一定要对上!!!

3.检查字段是否出现sql关键字!(比如call),这个很重要,因为call在java中并不是关键字,但是在sql中是关键字!

 

 service 打成可执行性的jar包

https://blog.csdn.net/qq_37105358/article/details/79467401

 

Spring boot同时兼容http与https 地址栏输入http跳转到https

import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan("com.huawei.clouddragon.mapper")
public class Application extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
            @Override
            protected void postProcessContext(Context context) {
                SecurityConstraint securityConstraint = new SecurityConstraint();
                securityConstraint.setUserConstraint("CONFIDENTIAL");//confidential
                SecurityCollection collection = new SecurityCollection();
                collection.addPattern("/*");
                securityConstraint.addCollection(collection);
                context.addConstraint(securityConstraint);
            }
        };
        tomcat.addAdditionalTomcatConnectors(httpConnector());
        return tomcat;
    }

    @Bean
    public Connector httpConnector() {
        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        connector.setScheme("http");
        connector.setPort(8080);
        connector.setSecure(false);
        connector.setRedirectPort(8443);
        return connector;
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

配置文件:application.properties

#ssl

server.port=28443
server.ssl.key-store=classpath:cmkey
#server.ssl.key-alias=tomcat
server.ssl.enabled=true
server.ssl.key-store-password=huawei
server.ssl.key-store-type=JKS

 

你可能感兴趣的:(【springboot】 springboot工程搭建及常见问题)