Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Astral-Yang committed Feb 28, 2023
1 parent 0e5ebf5 commit dcea4ea
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
19 changes: 19 additions & 0 deletions src/main/java/com/astral/dao_blog/config/FrontendConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.astral.dao_blog.config;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.boot.web.server.ErrorPage;

@Configuration
public class FrontendConfig {
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryWebServerFactoryCustomizer(){
return factory -> {
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html");
factory.addErrorPages(error404Page);
};
}
}
10 changes: 3 additions & 7 deletions src/main/java/com/astral/dao_blog/config/WebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
Expand All @@ -12,15 +11,12 @@ public class WebSecurityConfig {
SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/api/**").permitAll()
.antMatchers("/admin/**").authenticated()
.anyRequest().permitAll()
.and().formLogin()
.and().logout().logoutSuccessUrl("/")
.and().headers().frameOptions().sameOrigin()
.and().csrf().disable();
return httpSecurity.build();
}

@Bean
WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().antMatchers("/article/**");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.List;

@RestController
//跨域
@CrossOrigin
public class ArticleController {
@Autowired
ArticleService articleService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;

@RestController
@CrossOrigin
public class AssortController {

final AssortService assortService;
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/astral/dao_blog/util/articleInfo.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/java/com/astral/dao_blog/DaoBlogApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
package com.astral.dao_blog;

import com.astral.dao_blog.dao.ArticleDao;
import com.astral.dao_blog.service.AssortService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.FileNotFoundException;

@SpringBootTest
class DaoBlogApplicationTests {
@Autowired
AssortService assortService;
@Autowired
ArticleDao articleDao;

@Test
void contextLoads() throws FileNotFoundException {
}
}

0 comments on commit dcea4ea

Please sign in to comment.