Привет, я тестирую свои методы контроллеров с помощью реслета клиента Chrome, и у меня появляется ошибка 404, после проверки всего в моем проекте я создал новый и создал только один сервис и один контроллер, и все же все, что я получаю, это ошибка 404. любаяидеи?
это URL, который я называю: http://localhost:8080/rest/api/encryptor/checkAutorization
, это мой PomXML со всеми зависимостями:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.serverside</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>app</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
это контроллер:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import Services.GeneralResponse;
import Services.TokenEncryptor;
@RestController
@RequestMapping("rest/api/encryptor")
public class EncryptionController {
@Autowired
private TokenEncryptor tokenEncryptor;
@GetMapping("/checkAutorization")
public GeneralResponse checkAutorization() throws Throwable {
try {
// byte[] byteToken = token.getBytes(StandardCharsets.UTF_8);
return new GeneralResponse(tokenEncryptor.encryptToken(new byte[]
{}));
} catch (Exception AccessDeniedException) {
return new GeneralResponse(AccessDeniedException);
}
}
}
Основной метод:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
@Configuration
@SpringBootApplication
public class AppApplication {
public static void main(String[] args) {
SpringApplication.run(AppApplication.class, args);
}
}
Общий класс ответа:
import java.text.SimpleDateFormat;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GeneralResponse {
private Object error;
private Object result;
public GeneralResponse() {
}
public GeneralResponse(Object result) {
this.result = result;
}
public GeneralResponse(Exception e) {
this.result = null;
this.error = e;
StackTraceElement[] stackTrace = e.getStackTrace();
System.out.println("The exception occured in method " + stackTrace[0].getMethodName());
System.out.println("The class name is " + stackTrace[0].getClassName());
System.out.println("at line number: " + stackTrace[0].getLineNumber());
System.out.println(e.toString() + " \n" + "error cause: " + e.getCause() + "\n" + "at: " + formatTime(System.currentTimeMillis()));
}
public Object getError() {
return error;
}
public void setError(Object error) {
this.error = error;
}
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
private String formatTime(Long currentTime) {
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
Date resultdate = new Date(currentTime);
return (sdf.format(resultdate));
}
}
Журнал запуска консоли:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE)
2018-12-17 13:40:20.763 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : Starting AppApplication on LAPTOP-0GNLE6KN with PID 21872 (C:\Users\omert\eclipse-workspace\app\target\classes started by omert in C:\Users\omert\eclipse-workspace\app)
2018-12-17 13:40:20.766 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : No active profile set, falling back to default profiles: default
2018-12-17 13:40:20.814 INFO 21872 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2018-12-17 13:40:20.815 INFO 21872 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2018-12-17 13:40:21.546 INFO 21872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2018-12-17 13:40:21.569 INFO 21872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15ms. Found 0 repository interfaces.
2018-12-17 13:40:21.946 INFO 21872 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$365e8361] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-12-17 13:40:22.515 INFO 21872 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-12-17 13:40:22.541 INFO 21872 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-12-17 13:40:22.542 INFO 21872 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2018-12-17 13:40:22.554 INFO 21872 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_181\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_191/bin/server;C:/Program Files/Java/jre1.8.0_191/bin;C:/Program Files/Java/jre1.8.0_191/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\omert\AppData\Local\Microsoft\WindowsApps;C:\Users\omert\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\node.exe;;C:\WINDOWS\system32;;.]
2018-12-17 13:40:22.697 INFO 21872 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-12-17 13:40:22.697 INFO 21872 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1882 ms
2018-12-17 13:40:22.915 INFO 21872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-12-17 13:40:23.063 INFO 21872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-12-17 13:40:23.109 INFO 21872 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-12-17 13:40:23.178 INFO 21872 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.7.Final}
2018-12-17 13:40:23.181 INFO 21872 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-12-17 13:40:23.338 INFO 21872 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2018-12-17 13:40:23.482 INFO 21872 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-12-17 13:40:23.713 INFO 21872 --- [ restartedMain] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@77c8a0a2'
2018-12-17 13:40:23.716 INFO 21872 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-12-17 13:40:23.731 INFO 21872 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-12-17 13:40:23.983 INFO 21872 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-12-17 13:40:24.038 WARN 21872 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-12-17 13:40:24.325 INFO 21872 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-12-17 13:40:24.329 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : Started AppApplication in 3.869 seconds (JVM running for 4.415)