我是春季靴子的新手,我的问题很简单,但是我找不到问题所在。
我有一个基本的@GetMapping和@DeleteMapping
@RestController
public class MyController
{
private MyServiceImpl myService;
@Autowired
public MyController(MyServiceImpl myService)
{
this.myService = myService;
}
@GetMapping("/test")
public List<Scan> getTestData(@RequestParam(value = "test_id", required = true) String test_id) {
return myService.findByTestId( test_id );
}
@DeleteMapping("/test")
public int deleteData(@RequestParam(value = "test_id", required = true) String test_id){
return myService.deleteTest( test_id );
}
@DeleteMapping("/test2")
public String deleteArticle() {
return "Test";
}
}
我正在与Postman进行测试,Get请求正在工作,但删除请求却没有。即使当我调试spring boot应用程序时。 GetMapping被调用,而删除不是“反应” /被调用
也许信息不够,但是我什至测试了 @DeleteMapping(“ / test2”)没有做任何事情,我的意思是,我没有任何反应,在Postman中它保持“正在加载。” 。”
有什么建议吗?
我完整的POM
http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0
<parent>
<groupId>com.ttt.pdt</groupId>
<artifactId>pdt-base</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>pdt-service</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
父级(以pdt为基础)具有
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
MyServiceImpl
@Service
public class MyServiceImpl
{
private ScnDao scnDao;
@Autowired
public ScanServiceImpl(ScnDao scnDao){
this.scnDao = scnDao;
}
public int deleteTest( String test_id )
{
return scnDao.deleteTest( test_id );
}
}
public interface ScanDao
{
int deleteTest( String test_id )
}
@Repository
public class ScnPostgres implements ScnDao
{
private JdbcTemplate jdbcTemplate;
@Autowired
public ScnPostgres( JdbcTemplate jdbcTemplate )
{
this.jdbcTemplate = jdbcTemplate;
}
public int deleteTest( String test_id )
{
String SQL = "DELETE FROM scn WHERE test_id = ?";
return jdbcTemplate.update( SQL, new String[] { test_id } );
}
}
答案 0 :(得分:0)