Skip to content

Commit e6e6972

Browse files
committed
add message locale
1 parent 53ba3fb commit e6e6972

File tree

15 files changed

+202
-12
lines changed

15 files changed

+202
-12
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.codingapi.springboot</groupId>
1212
<artifactId>springboot-framework-parent</artifactId>
13-
<version>0.0.14</version>
13+
<version>0.0.15</version>
1414

1515
<url>https://github.com/codingapi/springboot-framewrok</url>
1616
<name>springboot-framework-parent</name>

springboot-data-permission/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-framework-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>0.0.14</version>
8+
<version>0.0.15</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -32,7 +32,7 @@
3232
<dependency>
3333
<groupId>com.codingapi.springboot</groupId>
3434
<artifactId>springboot-framework</artifactId>
35-
<version>0.0.14</version>
35+
<version>0.0.15</version>
3636
</dependency>
3737

3838
<dependency>
@@ -44,7 +44,6 @@
4444
<dependency>
4545
<groupId>com.h2database</groupId>
4646
<artifactId>h2</artifactId>
47-
<version>1.4.200</version>
4847
<scope>test</scope>
4948
</dependency>
5049

springboot-example/pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-framework-parent</artifactId>
7-
<version>0.0.14</version>
7+
<version>0.0.15</version>
88
</parent>
99
<artifactId>springboot-example</artifactId>
10-
<version>0.0.14</version>
10+
<version>0.0.15</version>
1111

1212
<name>springboot-example</name>
1313
<description>springboot-example project for Spring Boot</description>
@@ -24,18 +24,17 @@
2424
<dependency>
2525
<groupId>com.h2database</groupId>
2626
<artifactId>h2</artifactId>
27-
<version>1.4.200</version>
2827
</dependency>
2928

3029
<dependency>
3130
<groupId>com.codingapi.springboot</groupId>
3231
<artifactId>springboot-framework</artifactId>
33-
<version>0.0.14</version>
32+
<version>0.0.15</version>
3433
</dependency>
3534

3635
<dependency>
3736
<groupId>org.springframework.boot</groupId>
38-
<artifactId>spring-boot-starter</artifactId>
37+
<artifactId>spring-boot-starter-web</artifactId>
3938
</dependency>
4039

4140
</dependencies>

springboot-example/src/main/java/com/codingapi/springboot/example/ExampleApplication.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.web.servlet.LocaleResolver;
7+
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
58

6-
@SpringBootApplication(scanBasePackages = "com.codingapi.springboot.example")
9+
import java.util.Locale;
10+
11+
@SpringBootApplication
712
public class ExampleApplication {
813

914
public static void main(String[] args) {
1015
SpringApplication.run(ExampleApplication.class, args);
1116
}
1217

18+
/**
19+
* 默认配置文件,更改为中文
20+
*/
21+
@Bean
22+
public LocaleResolver localeResolver() {
23+
SessionLocaleResolver slr = new SessionLocaleResolver();
24+
slr.setDefaultLocale(Locale.CHINA);
25+
return slr;
26+
}
1327
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.codingapi.springboot.example.controller;
2+
3+
import com.codingapi.springboot.framework.exception.MessageException;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RestController;
6+
7+
@RestController
8+
public class DemoController {
9+
10+
@GetMapping("/hello")
11+
public String hello(){
12+
throw new MessageException("hello.error");
13+
}
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello.error=Hello Error
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello.error=Hello Error
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello.error=你好 出错了

springboot-framework/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-framework-parent</artifactId>
7-
<version>0.0.14</version>
7+
<version>0.0.15</version>
88
</parent>
99
<artifactId>springboot-framework</artifactId>
10-
<version>0.0.14</version>
10+
<version>0.0.15</version>
1111

1212
<name>springboot-framework</name>
1313
<description>springboot-framework project for Spring Boot</description>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.codingapi.springboot.framework.exception;
2+
3+
4+
public class BaseException extends RuntimeException{
5+
6+
public BaseException() {
7+
}
8+
9+
public BaseException(String message) {
10+
super(message);
11+
}
12+
13+
public BaseException(String message, Throwable cause) {
14+
super(message, cause);
15+
}
16+
17+
public BaseException(Throwable cause) {
18+
super(cause);
19+
}
20+
21+
public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
22+
super(message, cause, enableSuppression, writableStackTrace);
23+
}
24+
}

0 commit comments

Comments
 (0)