diff --git "a/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-1-351円205円215円347円275円256円346円226円207円344円273円266円.md" "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-1-351円205円215円347円275円256円346円226円207円344円273円266円.md" new file mode 100644 index 0000000..450b7a4 --- /dev/null +++ "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-1-351円205円215円347円275円256円346円226円207円344円273円266円.md" @@ -0,0 +1,287 @@ + + +# 一、Spring Boot学习笔记-配置文件 + +#### 1.yaml语法 + +基本语法:k:(空格)v :表示一对键值对,注意的是空格不能省略,以空格的缩进来控制层级关系,左对齐的一列数据就是同一个层级的。注意的是属性和值也是大小写敏感的。例如 + +~~~yaml +spring: + datasource: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/swrhdemo1 + username: root + password: 1234 + jpa: + database: mysql + show-sql: true +server: + port: 8080 +~~~ + +#### 2.值的写法 + +值为普通的值(数字,字符串,布尔):k: v :就直接写值,注意,字符串默认不用添加单引号和双引号。 + +"":双引号:不会转义字符串里面的特殊字符;特殊字符会作为本身想表达的意思 + +'':单引号:会转义字符串里面的特殊字符,特殊字符最终就是一个普通的字符 + +值为对象,Map使用k: 下一行写对象的属性和值 + +值为集合,使用k: 下一行使用-(空格)值来书写。所有数据结构的书写方法如下所示, + +~~~yaml +person: + name: "张三\n李四" + age: 14 + map: {k1: V1,k2: V2} + list: + - cat + - dog + - pig + cat: + name: '小猫\n小狗' + age: 4 +~~~ + +上述yaml文件锁对应的Javabean如下所示: + +~~~ java +@Component +@ConfigurationProperties(prefix = "person") +public class Person { + + private String name; + + private int age; + + private Map map = new HashMap(); + + private List list = new ArrayList(); + + private Cat cat; +~~~ + +说明: + +1. @ConfigurationProperties(prefix = "person")注解是获取yaml文件中的配置 +2. 其中prefix = "person"表示获取yaml中前缀为person的值 +3. 要使用ConfigurationProperties注解,最好在pom.xml文件中做如下配置 + +~~~ xml + + org.springframework.boot + spring-boot-configuration-processor + true + +~~~ + +#### 3.配置文件注入 + +从前面我们可以知道将配置文件中属性和值注入到bean实体类中,我们可以使@ConfigurationProperties注解,除此之外,我们还可以使用@Value注解,使用方法如下: + +~~~ java +@Component +public class Person { + @Value("${person.name}") + private String name; + @Value("#{11*2}") + private int age; + + private Map map = new HashMap(); + + private List list = new ArrayList(); + + private Cat cat; +~~~ + +注意的是:@Value注解只能用于基本类型的值注入,与@ConfigurationProperties注解的区别如下: + +| | @ConfigurationProperties | @Value | +| ---------- | ------------------------ | ------ | +| 功能 | 批量注入配置文件中的属性 | 单个指定 | +| 松散绑定 | 支持 | 不支持 | +| SpEL | 不支持 | 支持 | +| JSR303数据校验 | 支持 | 不支持 | +| 复杂类型封装 | 支持 | 不支持 | + +使用JSR303进行字段校验的同时,在bean类上使用@Validated注解。 + +#### 4.外部配置文件 + +使用@PropertySource(value ={"classpath: person.properties"})加载指定的配置文件 + +其中person.properties书写如下: + +~~~properties +person.last-name=\u674E\u56DB +person.age=12 +person.birth=2017年12月15日 +person.boss=false +person.maps.k1=v1 +person.maps.k2=14 +person.lists=a,b,c +person.dog.name=dog +person.dog.age=15 +~~~ + +使用@ImportResource(locations = {"classpath: beans.xml"})注解加载Spring配置文件。如下 + +~~~xml + + + + + +~~~ + +但是,在SpringBoot中不推荐再继续使用xml配置文件来启动项目,推进使用全注解的方式来给容器添加组件,使用@bean注解和@Configuration注解,如下: + +说明: + +1. @Configuration注解指明当前类是一个配置类,就是用来代替之前的Spring.xml配置文件 +2. 在Spring.xml文件中,使用标签来添加组件,在配置类中使用@bean注解 +3. @bean注解标记在方法中就是将方法的返回值添加到容器中,容器中这个组件的默认id就是方法名 + +~~~java +@Configuration +public class APPConfig { + @Bean + public HelloServices helloServices(){ + return new HelloServices(); + } +} +~~~ + +#### 5.配置文件中的占位符 + +配置文件中可以使用随机数:${random.value/int/long}等。 + +也可以在配置文件中引用前面已经配置了的属性:${app.name:默认值} + +~~~yaml +person: + name: "张三\n李四${random.int}" + age: 14 + map: {k1: V1,k2: V2} + list: + - cat + - dog + - pig + cat: + name: '${person.name}小猫\n小狗' + age: 4 +~~~ + +#### 6.Profile多环境支持 + +1. 使用多Profile文件的方法,在编写配置文件名时带上不同环境的标识,文件名application-{profile}.yml +2. 使用yaml多文档块的方式 +3. 激活指定的profile + +第一种方法就是在建立不同的配置文件application.yml、application-dev.yml、application-pro.yml。程序默认使用application.yml,在application.yml中使用spring.profiles.active=dev来激活指定的配置文件。 + +第二种配置方法如下 + +~~~yaml +server: + port: 8080 +Spring: + profiles: + active: dev +--- +server: + port: 8081 +spring: + profiles: dev +--- +server: + port: 8084 +spring: + profiles: pro +~~~ + +激活指定环境也可以在项目打成jar包的时候使用命令的形式java -jar jar名 --spring.profiles.active=dev + +#### 7.配置文件加载位置 + +SpringBoot启动的时候会扫描以下位置的application.yml文件作为SpringBoot的默认配置文件 + +1. file:./config/ 项目根目录下的config文件 +2. file:./ 项目根目录下 +3. classpath:/config/ 项目src/main/resources/config目录下 +4. classpath:/ 项目src/main/resources/目录下 + +以上是按照优先级从高到底的顺序,所有位置的文件都会被加载,高优先级配置会覆盖低优先级配置的内容。 + +可以通过spring.config.location来改变默认配置,使用方法就是在项目打包后使用的命令的形式将外在配置文件和项目的配置文件形成互补, + +java -jar jar名 --spring.config.location=D:/application.yml + +#### 8.自动配置原理 + +application.yml文件中到底都能配置什么,详情参考[SpringBoot官方文档](https://docs.spring.io/spring-boot/docs/1.5.10.RELEASE/reference/htmlsingle/#common-application-properties) + +1. SpringBoot启动的时候加载主配置类,在主配置类中使用了@SpringBootApplication注解,点进去发现会开启@EnableAutoConfiguration注解自动配置。 +2. @EnableAutoConfiguration的作用:利用@Import({AutoConfigurationImportSelector.class})给容器中导入一些组件,点进去找到selectImports方法中List configurations = this.getCandidateConfigurations(annotationMetadata, attributes); +3. SpringFactoriesLoader.loaFactoryNames()扫描所有jar包类路径下WETN_INF/Spring.factories,把扫描到的这些文件的内容包装成一个properties对象,从properties中获取EnableAutoConfiguration.class类(类名)对应的值,然后将他们添加到容器中 + +**总结将类路径下WETA-INF/Spring.factories里面配置的所有EnableAutoConfiguration的值加入到容器中** + +以HttpEncodingAutoConfiguration为例解释自动配置原理 + +~~~java +@Configuration //表示这是一个配置类 +@EnableConfigurationProperties({HttpEncodingProperties.class}) +//启动指定类的ConfigurationProperties功能 +@ConditionalOnWebApplication(//Spring底层有@conditiona注解,根据不同的条件,如果满足指定的条件才会让配置类中的配置就会生效,判断当前应用是否为web应用。 + type = Type.SERVLET +) +@ConditionalOnClass({CharacterEncodingFilter.class}) +//判断当前项目中有没有CharacterEncodingFilter这个类 +@ConditionalOnProperty(//判断配置文件中是否存在某个配置spring.http.encoding + prefix = "spring.http.encoding", + value = {"enabled"}, + matchIfMissing = true +) +~~~ + +根据当前不同的条件判断,决定这个配置类是否生效。 + +所有可以在配置文件中能配置的属性都是在xxxProperties类中封装着,配置文件能配置什么就可以参照某个功能对应的这个属性类 + +~~~java +@ConfigurationProperties( + prefix = "spring.http.encoding" +)//从配置文件中获取指定的值和bean的属性进行绑定,也就是说在yaml文件中可以配置spring.http.encoding +public class HttpEncodingProperties { +~~~ + +#### 9.SpringBoot自动配置的精髓 + +SpringBoot在启动的时候就会加载大量的自动配置类 + +我们看我们需要的功能有没有在SpringBoot默认写好的自动配置文件类中,如果自动配置文件类中有我们需要的组件,就不在需要我们配置。 + +1、快捷键Alt+Shift+N打开自动搜索,输入*AutoConfiguration,选择自己需要的配置文件类 + +2、在配置文件类中选择注解xxxProperties.class + +3、在ConfigurationProperties注解后面就是可以配置的属性名,字段名就是属性值 + +自动配置文件类只有满足条件才能生效,如何知道那些自动配置类生效,使用方法如下: + +~~~yaml +debug: true +~~~ + +在yaml文件中配置应用以debug模式来启动,在控制台就会打印那些自动配置类已经生效了。其中Negative matches就是没有生效的配置类。Positive matches就是生效的自动配置。 + + + + + diff --git "a/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-2-346円227円245円345円277円227円346円241円206円346円236円266円.md" "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-2-346円227円245円345円277円227円346円241円206円346円236円266円.md" new file mode 100644 index 0000000..fd378f0 --- /dev/null +++ "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-2-346円227円245円345円277円227円346円241円206円346円236円266円.md" @@ -0,0 +1,217 @@ +# SpringBoot中的日志框架学习 + +日志框架中我们选择的是SLF4J日志门面。日志实现选择的是Logback。调用日志记录的方法,不应该直接调用实现类,而是调用日志抽象层里面的方法。 + +## 1.使用slf4j的方法 + +给系统导入slf4j包和日志实现Logback包,如果要使用log4j,就导入slf4j和slf4j-log4、log4j包 + +~~~java +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HelloWorld { + public static void main(String[] args) { + Logger logger = LoggerFactory.getLogger(HelloWorld.class); + logger.info("Hello World"); + } +} +~~~ + +![img](https://www.slf4j.org/images/concrete-bindings.png) + +每一个日志的实现框架都有自己的配置文件,使用slf4j以后,配置文件还是写日志实现框架的配置文件。 + +## 2.统一日志记录 + +### 统一日志框架官方图示 + +![img](https://www.slf4j.org/images/legacy.png) + +### 统一日志框架方法总结 + +1、将系统中的其他日志框架先排除出去。 + +2、用中间包来替换原有的日志框架。 + +3、我们导入slf4j其他的实现 + +## 3.SpringBoot中的日志关系 + +~~~xml + + org.springframework.boot + spring-boot-starter + 2.0.0.RELEASE + compile + +~~~ + +SpringBoot使用下面的日志 + +~~~xml + + org.springframework.boot + spring-boot-starter-logging + 2.0.0.RELEASE + compile + +~~~ + +SpringBoot日志依赖图示 + +![](图片素材/6.png) + +SpringBoot底层使用slf4j+logback的方式进行日志记录。同时将其他日志框架也装换为slf4框架。 + +如果我们使用其他框架,就先把这个框架的默认日志框架给排除,例如我们使用Spring,就先排除Spring默认的commons-logging日志框架。 + +## 4.SpringBoot中使用slf4j + +SpringBoot默认配置了日志框架,我们直接就可以使用,如下 + +~~~java +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringBootConfigApplicationTests { + + //日志记录器 + Logger logger = LoggerFactory.getLogger(getClass()); + + @Test + public void contextLoads() { + //日志级别,由低到高,可以调整输入的日志级别,日志就只会在这个级别和更高的级别生效 + logger.trace("这是trace日志"); + logger.debug("这是debug日志"); + //SpringBoot默认使用的是info级别的,即trace和debug不会被打印输出 + logger.info("这是自定义的info日志"); + logger.warn("这是警告日志"); + logger.error("这是错误日志"); + } + +} +~~~ + +修改日志级别的方法,添加配置文件 + +~~~yaml +logging: + level: debug +~~~ + +指定日志文件输出位置 + +| logging.file | logging.path | Example | Desciption | +| ------------ | ------------ | -------- | --------------------- | +| (none) | (none) | | 只在控制台输出 | +| 指定文件名 | (none) | my.log | 输出日志到my.log文件 | +| (none) | 指定目录 | /var/log | 输出到指定目录的spring.log文件中 | + +logging.file不指定路径在当前项目下生成springboot.log文件,也可以指定路径D:/springboot.log + +logging.path指定为/spring/log就会在当前磁盘的根路径下创建一个spring文件夹和log文件夹,使用spring.log为日志文件。 + +## 5.使用自己的配置文件 + +如果使用logback配置文件,就吧logback.xml放在项目resources目录下即可, + +~~~xml + + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + + + + ${LOG_HOME}/${appName}.log + + + + ${LOG_HOME}/${appName}-%d{yyyy-MM-dd}-%i.log + + 365 + + + 100MB + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n + + + + + + + + + + + + + + + + + +~~~ + +如果将logback.xml更改为logback-spring.xml就是有SpringBoot解析日志配置,就可以使用SpringBoot的Profile功能,指定在某种开发环境下才生效。 + +~~~xml + + + %d{yyyy-MM-dd HH:mm:ss.SSS} ----> [%thread] ---> %-5level %logger{50} - %msg%n + + + %d{yyyy-MM-dd HH:mm:ss.SSS} ==== [%thread] ==== %-5level %logger{50} - %msg%n + + +~~~ + diff --git "a/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-3-web345円274円200円345円217円221円.md" "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-3-web345円274円200円345円217円221円.md" new file mode 100644 index 0000000..d6e253b --- /dev/null +++ "b/JavaEE350円277円233円351円230円266円347円237円245円350円257円206円345円255円246円344円271円240円-----SpringBoot347円237円245円350円257円206円347円263円273円347円273円237円345円255円246円344円271円240円-3-web345円274円200円345円217円221円.md" @@ -0,0 +1,334 @@ +# SpringBootWeb开发 + +## 1.SpringBoot静态资源映射规则 + +~~~java +public void addResourceHandlers(ResourceHandlerRegistry registry) { + if (!this.resourceProperties.isAddMappings()) { + logger.debug("Default resource handling disabled"); + } else { + Duration cachePeriod = this.resourceProperties.getCache().getPeriod(); + CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl(); + if (!registry.hasMappingForPattern("/webjars/**")) { + this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{"/webjars/**"}).addResourceLocations(new String[]{"classpath:/META-INF/resources/webjars/"}).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl)); + } + + String staticPathPattern = this.mvcProperties.getStaticPathPattern(); + if (!registry.hasMappingForPattern(staticPathPattern)) { + this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{staticPathPattern}).addResourceLocations(getResourceLocations(this.resourceProperties.getStaticLocations())).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl)); + } + + } + } + +~~~ + +1、所有的/webjars/**,都去classpath:/META-INF/resources/webjars/找资源 + +webjars:以jar包的方式引入资源,网页搜索webjars,选择maven的方式引入,例如引入jquery + +~~~xml + + org.webjars + jquery + 3.3.1 + +~~~ + +访问jQuery.js的路径为:localhost:8080/webjars/jquery/3.3.1/jquery.js + +2."/**"访问当前项目的任何资源,(静态资源的文件夹) + +~~~java +"classpath:/META-INF/resources/", +"classpath:/resources/", +"classpath:/static/", +"classpath:/public/" +"/":当前项目的根路径 +~~~ + +访问l路径:localhost:8080/asserts/js/bootstrap.min.js + +3.欢迎页面映射 + +~~~java + @Bean +public WelcomePageHandlerMapping welcomePageHandlerMapping(ApplicationContext applicationContext) { + return new WelcomePageHandlerMapping(new TemplateAvailabilityProviders(applicationContext), applicationContext, this.getWelcomePage(), this.mvcProperties.getStaticPathPattern()); +} +~~~ + +静态资源文件夹下的index.html,例如访问localhost:8080 + +4.映射网页小图标,在静态资源文件夹下找 + +~~~java +@Configuration +@ConditionalOnProperty( + value = {"spring.mvc.favicon.enabled"}, + matchIfMissing = true +) +public static class FaviconConfiguration implements ResourceLoaderAware { + private final ResourceProperties resourceProperties; + private ResourceLoader resourceLoader; + + public FaviconConfiguration(ResourceProperties resourceProperties) { + this.resourceProperties = resourceProperties; + } +~~~ + +项目结构如下图: + +![](图片素材/8.png) + +## 2.SpringBoot引入thymeleaf + +1、pom.xml文件中引入thymeleaf + +~~~xml + + org.springframework.boot + spring-boot-starter-thymeleaf + +~~~ + +2、默认使用的thymeleaf版本低,修改版本 + +~~~xml + + UTF-8 + UTF-8 + 1.8 + + 3.0.2.RELEASE + 2.1.1 + + +~~~ + +## 3.Thymeleaf基本使用 + +~~~java +@ConfigurationProperties( + prefix = "spring.thymeleaf" +) +public class ThymeleafProperties { + private static final Charset DEFAULT_ENCODING; + public static final String DEFAULT_PREFIX = "classpath:/templates/"; + public static final String DEFAULT_SUFFIX = ".html"; + private boolean checkTemplate = true; + private boolean checkTemplateLocation = true; + private String prefix = "classpath:/templates/"; + private String suffix = ".html"; + //只要我们将HTML页面存放在classpath:/templates/目录中,thymeleaf就能自动渲染 +~~~ + +注意:thymeleaf能渲染html页面,在Controller使用注解@Controller,不能使用@RestController注解。 + +使用thymeleaf方法如下: + +1. html页面引入thymeleaf域名空间 +2. Controller类中收发请求和传递数据 + +~~~html + + + + + 成功页面 + +
+

成功页面

+ + +

AltStyle によって変換されたページ (->オリジナル) /

+ +~~~ + +~~~java +@Controller +public class HelloController { + + @RequestMapping("/success") + public String success(Map map){ + map.put("hello","你好"); + return "success"; + } +} +~~~ + +## 4.Thymeleaf语法 + +1、th:text:改变当前元素的文本内容的;可以使用th:任意html属性:来替换原生属性的值 + +~~~html +
+~~~ + +~~~html +
你好
+~~~ + +| Order | Feature | Attributes | +| ----- | --------- | ---------------------------------------- | +| 1 | 片段包含 | `th:insert``th:replace` | +| 2 | 遍历 | `th:each` | +| 3 | 条件判断 | `th:if``th:unless``th:switch``th:case` | +| 4 | 声明变量 | `th:object``th:with` | +| 5 | 任意属性修改 | `th:attr``th:attrprepend``th:attrappend` | +| 6 | 修改指定属性默认值 | `th:value``th:href``th:src``...` | +| 7 | 修改标签体内容 | `th:text(转义特殊字符)th:utext(不转义)` | +| 8 | 声明片段 | `th:fragment` | +| 9 | 移除片段 | `th:remove` | + +2、表达式语法(参考thymeleaf官方文档第四章) + +~~~properties +Simple expressions:(表达式语法) + 一、Variable Expressions: ${...}:获取变量值,OGNL + 1、获取对象的属性,调用方法 + ${person.father.name} + ${person['father']['name']} + ${countriesByCode.ES} + ${personsByName['Stephen Zucchini'].age} + ${personsArray[0].name} + ${person.createCompleteName()} + ${person.createCompleteNameWithSeparator('-')} + 2、使用内置的对象(使用方法参见官方文档第四章的附录) + #ctx: the context object. + #vars: the context variables. + #locale: the context locale. + #request: (only in Web Contexts) the HttpServletRequest object. + #response: (only in Web Contexts) the HttpServletResponse object. + #session: (only in Web Contexts) the HttpSession object. + #servletContext: (only in Web Contexts) the ServletContext object. + 3、内置工具对象(使用方法参见官方文档第四章的附录) + #execInfo: + #messages: + #uris: + #conversions: + #dates: + #calendars: + #numbers: methods for formatting numeric objects. + #strings: + #objects: methods for objects in general. + #bools: methods for boolean evaluation. + #arrays: methods for arrays. + #lists: methods for lists. + #sets: methods for sets. + #maps: methods for maps. + #aggregates: + #ids: + 二、 Selection Variable Expressions: *{...}:选择表达式,功能和${}一样 +
+

Name: Sebastian.

+

Surname: Pepper.

+

Nationality: Saturn.

+
+ 配合 th:object="${session.user}"使用,*相当于th:object + 三、Message Expressions: #{...}:获取国际化内容 + 四、Link URL Expressions: @{...}:定义URL链接 + @{/order/process(execId=${execId},execType='FAST')} + 五、Fragment Expressions: ~{...}:片段引用 +Literals(字面量) + Text literals: 'one text', 'Another one!',... + Number literals: 0, 34, 3.0, 12.3,... + Boolean literals: true, false + Null literal: null + Literal tokens: one, sometext, main,... +Text operations:(文本操作) + String concatenation: + + Literal substitutions: |The name is ${name}| +Arithmetic operations:(数学运算) + Binary operators: +, -, *, /, % + Minus sign (unary operator): - +Boolean operations:(布尔运算) + Binary operators: and, or + Boolean negation (unary operator): !, not +Comparisons and equality:(比较运算) +Comparators:>, <,>=, <= (gt, lt, ge, le) +Equality operators: ==, != (eq, ne) +Conditional operators:(条件运算,三元运算符) + If-then: (if) ? (then) + If-then-else: (if) ? (then) : (else) + Default: (value) ?: (defaultvalue) +~~~ + +## 5.thymeleaf基本使用 + +controller数据准备如下: + +~~~java +@RequestMapping("/success") + public String success(Map map){ + map.put("hello","

你好

"); + map.put("list" , Arrays.asList("张三","李四","王五")); + return "success"; + } +~~~ + +~~~html + + + + + 成功页面 + + +

成功页面

+ +
+ US +
+ + +
+ +

+
+

+ + [[${user}]] +

+ + +~~~ + +## 6.扩展SpringMVC + +例如需要扩展如下SpringMVC功能: + +~~~xml + + + + + + + + + + + + + + +~~~ + +编写一配置类(@Configuration),继承WebMvcConfigurationSupport,不能标注@EnableWebMvc注解,需要扩展什么功能,就重写什么方法 + +~~~java +//使用WebMvcConfigurationSupport扩展SpringMVC的功能 +@Configuration +public class MyMvcConfig extends WebMvcConfigurationSupport { + + @Override + protected void addViewControllers(ViewControllerRegistry registry) { + //浏览器发送luo请求就直接来到success页面 + registry.addViewController("luo").setViewName("success"); + } +} +~~~ + diff --git "a/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----IDEA345円270円270円347円224円250円345円277円253円346円215円267円351円224円256円.md" "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----IDEA345円270円270円347円224円250円345円277円253円346円215円267円351円224円256円.md" new file mode 100644 index 0000000..1454edd --- /dev/null +++ "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----IDEA345円270円270円347円224円250円345円277円253円346円215円267円351円224円256円.md" @@ -0,0 +1,6 @@ +# IDEA常用快捷键 + +1. 生成方法返回类型:Ctrl+Alt+V +2. 全局搜索:Ctrl+Shift+N +3. 导包:Alt+Enter +4. 查看可以重写的方法:Ctrl+O \ No newline at end of file diff --git "a/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----Typroa345円277円253円346円215円267円351円224円256円.md" "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----Typroa345円277円253円346円215円267円351円224円256円.md" new file mode 100644 index 0000000..47cd2cc --- /dev/null +++ "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----Typroa345円277円253円346円215円267円351円224円256円.md" @@ -0,0 +1,23 @@ +### Typroa快捷键 + +- 无序列表:输入-之后输入空格 +- 有序列表:输入数字+"."之后输入空格 +- 任务列表:-[空格]空格 文字 +- 标题:ctrl+数字 +- 表格:ctrl+t +- 生成目录:[TOC]按回车 +- 选中一整行:ctrl+l +- 选中单词:ctrl+d +- 选中相同格式的文字:ctrl+e +- 跳转到文章开头:ctrl+home +- 跳转到文章结尾:ctrl+end +- 搜索:ctrl+f +- 替换:ctrl+h +- 引用:输入>之后输入空格 +- 代码块:ctrl+alt+f +- 加粗:ctrl+b +- 倾斜:ctrl+i +- 下划线:ctrl+u +- 删除线:alt+shift+5 +- 插入图片:直接拖动到指定位置即可或者ctrl+shift+i +- 插入链接:ctrl+k \ No newline at end of file diff --git "a/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----git345円237円272円346円234円254円344円275円277円347円224円250円.md" "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----git345円237円272円346円234円254円344円275円277円347円224円250円.md" new file mode 100644 index 0000000..99154f1 --- /dev/null +++ "b/Java345円274円200円345円217円221円345円267円245円345円205円267円345円255円246円344円271円240円----git345円237円272円346円234円254円344円275円277円347円224円250円.md" @@ -0,0 +1,11 @@ +# git上传项目到GitHub + +1. GitHub和本地配置SSH秘钥。 +2. GitHub上新建一个仓库 +3. 在本地项目文件夹的根目录下打开Git Base Here,输入一下命令 +4. git init +5. git add . +6. git commit -m"初次提交" +7. git remote add origin git@github.com:luokangyuan/SSH_Meal.git(GitHub复制的地址) +8. git push origin master + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0e7f77 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# JavaStudyNote +## 近来相关工作笔记,都是写杂碎的东西 +> 在linux服务器上用sftp存储文件, sftp 用户名@ip 端口 然后输入密码; +
scp -r 要上传到服务器的文件 用户名@ip:服务器路径 然后输入校验密码; +
远程命令 telnet 10.1.x.x 端口号; +
grep 关键字 logs.log,这种我是不建议的,现在用elk查看日志,比命令好多了,可能在**银行会有这种操作; +
docker version 版本 +
docker ps -a 查看所有的进程 +
docker images -a 查看所有的镜像 +
docker exec -it 容器ID /bin/bash 进入某个容器 +
docker kill 容器ID 关闭某个容器 +
docker inspect 容器ID 查看容器内部配置信息 +
docker cp /etc/localime容器ID:/etc/ 把文件copy到容器 +
docker system prune -a 然后确定写y 清掉停止的容器 +
docker system df 分析磁盘情况 + +> 线上碰到的问题 +>> Java.lang.NoClassDefFoundError:Could not initialize class sun.awt.X11GraphicsEnvironment +后面还有很多行抛出的错误提示;这个问题当时在开发环境是没问题的,但是在服务器环境不能正常渲染验证码。 +这个服务器如果是weblogic的话,vim setDomainEnv.sh编辑这个文件夹,在该文件的的JAVA_OPTIONS="" ,在这个双引号中加入-Djava.awt.headless=true +重启下weblogic就好了。 +如果部署在tomcat上的话,在catalina.sh中加上 一句 CATALINA_OPTS=-Djava.awt.headless=true + +>> sftp上传文件遇到的问题,抛出No Configuration was registered that can handle the configuration named com.sun.security.jgss.krb5.initiate +这个在开发环境是能正常上传文件比如上传图片,在sit环境也是可以的,后面在uat环境是不可以的。 +后面尝试对jar版本降低,这个问题就没有了。 +sftp这里用的jar是jsch + + + + + + + diff --git "a/345円233円276円347円211円207円347円264円240円346円235円220円/6.png" "b/345円233円276円347円211円207円347円264円240円346円235円220円/6.png" new file mode 100644 index 0000000..b8787bf Binary files /dev/null and "b/345円233円276円347円211円207円347円264円240円346円235円220円/6.png" differ diff --git "a/345円233円276円347円211円207円347円264円240円346円235円220円/7.png" "b/345円233円276円347円211円207円347円264円240円346円235円220円/7.png" new file mode 100644 index 0000000..9e28154 Binary files /dev/null and "b/345円233円276円347円211円207円347円264円240円346円235円220円/7.png" differ diff --git "a/345円233円276円347円211円207円347円264円240円346円235円220円/8.png" "b/345円233円276円347円211円207円347円264円240円346円235円220円/8.png" new file mode 100644 index 0000000..a3277aa Binary files /dev/null and "b/345円233円276円347円211円207円347円264円240円346円235円220円/8.png" differ diff --git "a/350円275円257円344円273円266円345円274円200円345円217円221円347円232円204円344円272円272円347円224円237円-----2018345円271円264円347円232円204円345円255円246円344円271円240円350円256円241円345円210円222円.md" "b/350円275円257円344円273円266円345円274円200円345円217円221円347円232円204円344円272円272円347円224円237円-----2018345円271円264円347円232円204円345円255円246円344円271円240円350円256円241円345円210円222円.md" index efc8ad5..04381da 100644 --- "a/350円275円257円344円273円266円345円274円200円345円217円221円347円232円204円344円272円272円347円224円237円-----2018345円271円264円347円232円204円345円255円246円344円271円240円350円256円241円345円210円222円.md" +++ "b/350円275円257円344円273円266円345円274円200円345円217円221円347円232円204円344円272円272円347円224円237円-----2018345円271円264円347円232円204円345円255円246円344円271円240円350円256円241円345円210円222円.md" @@ -1,5 +1,5 @@ ###疾风知劲草,智者必怀仁 -2017年7月大学毕业,学习一刻也不能停歇,只有不断的学习充实自己才有更好的未来。2018勉励自己,努力的完善自己的知识体系。 +大学计算机专业毕业几年,学习一刻也不能停歇,只有不断的学习充实自己才有更好的未来。在以后的工作生涯,努力的完善自己的知识体系。 ![](https://i.imgur.com/OKjpRkw.png) -###付出总会有回报的,我相信明天,每一个为梦想奋斗的人都会得到上天的眷顾,厚积终会爆发,不放弃。 \ No newline at end of file +###付出总会有回报的,我相信明天,每一个为梦想奋斗的人都会得到上天的眷顾,厚积终会爆发,不放弃。