修改了启动模式
This commit is contained in:
parent
9be237c53e
commit
f3c4056c1e
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
@ -7,7 +7,6 @@
|
|||||||
"hostName": "localhost",
|
"hostName": "localhost",
|
||||||
"port": "5005"
|
"port": "5005"
|
||||||
},
|
},
|
||||||
java
|
|
||||||
{
|
{
|
||||||
"type": "java",
|
"type": "java",
|
||||||
"name": "CriticalScenarioApplication",
|
"name": "CriticalScenarioApplication",
|
||||||
|
|||||||
@ -51,6 +51,23 @@
|
|||||||
4. 增加 OpenAPI 文档与前端集成接口规范。
|
4. 增加 OpenAPI 文档与前端集成接口规范。
|
||||||
5. 引入结果持久化与查询报表。
|
5. 引入结果持久化与查询报表。
|
||||||
|
|
||||||
|
## 调试与开发指南
|
||||||
|
|
||||||
|
### Maven 命令行启动 + 远程调试
|
||||||
|
|
||||||
|
如果您偏好使用命令行启动,或者需要模拟特定的 Maven 环境,可采用以下方式:
|
||||||
|
|
||||||
|
1. **启动应用**:
|
||||||
|
在终端中运行以下命令,该命令会以调试模式启动应用并监听 `5005` 端口(`suspend=n` 表示不等待调试器连接直接启动,如需等待可改为 `y`)。
|
||||||
|
> 注意:PowerShell 中需要使用单引号包裹 JVM 参数,防止解析错误。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn -DskipTests spring-boot:run -pl business-css '-Dspring-boot.run.jvmArguments=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **附加调试器**:
|
||||||
|
应用启动后,转到 IDE 的 "运行和调试" (Run and Debug) 面板,选择 **"Attach to Remote Program(5005)"** 配置(需确保 `.vscode/launch.json` 中已存在相应配置),然后点击运行。IDE 将连接到正在运行的 Maven 进程,即可开始断点调试。
|
||||||
|
|
||||||
## 运维与配置
|
## 运维与配置
|
||||||
- 端口默认 `8082`,环境覆盖通过 `application.yml` 与外部化配置。
|
- 端口默认 `8082`,环境覆盖通过 `application.yml` 与外部化配置。
|
||||||
- 数据库连接按环境注入(dev/test/prod)。
|
- 数据库连接按环境注入(dev/test/prod)。
|
||||||
|
|||||||
@ -66,6 +66,13 @@
|
|||||||
<classifier>plain</classifier>
|
<classifier>plain</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 显式添加 MyBatis-Plus 依赖,确保测试环境类加载正确 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.5.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- Lombok -->
|
<!-- Lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.yfd.platform.config.bean.LoginProperties;
|
|||||||
import com.yfd.platform.exception.AccessDeniedHandExcetion;
|
import com.yfd.platform.exception.AccessDeniedHandExcetion;
|
||||||
import com.yfd.platform.exception.AuthenticationException;
|
import com.yfd.platform.exception.AuthenticationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -19,6 +20,9 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
// 1. 注入配置项,默认为 false
|
||||||
|
@Value("${security.dev.permit:false}")
|
||||||
|
private boolean devPermit;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PasswordEncoder passwordEncoder() {
|
public PasswordEncoder passwordEncoder() {
|
||||||
@ -50,8 +54,12 @@ public class SecurityConfig {
|
|||||||
http
|
http
|
||||||
.csrf(csrf -> csrf.disable())
|
.csrf(csrf -> csrf.disable())
|
||||||
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> {
|
||||||
.requestMatchers("/user/login").anonymous()
|
// 如果配置为 true,则允许所有请求
|
||||||
|
if (devPermit) {
|
||||||
|
auth.anyRequest().permitAll();
|
||||||
|
} else {
|
||||||
|
auth.requestMatchers("/user/login").anonymous()
|
||||||
.requestMatchers("/user/code").permitAll()
|
.requestMatchers("/user/code").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET,
|
.requestMatchers(HttpMethod.GET,
|
||||||
"/*.html",
|
"/*.html",
|
||||||
@ -73,8 +81,9 @@ public class SecurityConfig {
|
|||||||
"/avatar/**",
|
"/avatar/**",
|
||||||
"/systemurl/**",
|
"/systemurl/**",
|
||||||
"/api/imageserver/upload").permitAll()
|
"/api/imageserver/upload").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated();
|
||||||
)
|
}
|
||||||
|
})
|
||||||
.cors(cors -> {});
|
.cors(cors -> {});
|
||||||
|
|
||||||
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user