Я пытался развернуть приложения Springboot.Я попробовал один и смог успешно развернуть Springboot с контроллером rest на встроенный tomcat.Теперь я пытаюсь сделать еще одно, где я хочу упаковать его как проект веб-приложения и развернуть на tomcat.Я могу развернуть его, но он не разрешается правильно для остальных путей контроллера и выдает ошибку http 404.Я делаю это с помощью gradle build.
свойство contextpath не работает.
Мое приложение запускается http://localhost:8080/projectName/Welcome.jsp.Мне нужно дать это внешне.Он пытается перейти на http: localhost: 8080 / Students по нажатию моей ссылки в JSP.
Это выдает ошибку - Тип Состояние отчета
Сообщение / студенты
Описание Исходный сервер не нашел текущее представление для целевого ресурса или не желает раскрывать этоодин существует.
мой файл Gradle:
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you
started.
* For more details take a look at the Java Libraries chapter in the
Gradle
* user guide available at
https://docs.gradle.org/4.3/userguide/java_library_plugin.html
*/
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'java-library'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.5'
classpath("org.springframework.boot:spring-boot-gradle-
plugin:2.0.5.RELEASE")
//testImplementation 'junit:junit:4.12'
}
}
apply plugin: 'com.bmuschko.tomcat'
sourceCompatibility = 1.8
targetCompatibility = 1.8
bootWar{
mainClassName = 'org.sjsu.eds.student.main.StudentMain'
}
dependencies {
// This dependency is exported to consumers, that is to say found
on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers
on their own compile classpath.
implementation 'com.google.guava:guava:23.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
def tomcatVersion = '9.0.8'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:9.0.0.M6",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
/*reference - https://github.com/bmuschko/gradle-tomcat-
plugin/blob/master/README.md*/
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile ("org.apache.httpcomponents:httpclient:4.5.7")
compile ("org.springframework:spring-webmvc:4.1.6.RELEASE")
}
tomcat {
httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol'
ajpProtocol = 'org.apache.coyote.ajp.AjpNio2Protocol'
}
Основной файл моей пружины
@SpringBootApplication
public class StudentMain extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder
application) {
return application.sources(StudentMain .class);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SpringApplication.run(StudentMain.class, args);
}
}
Мой контроллер покоя простой
@RestController
@RequestMapping(value="/students")
public class StudentController {
private StudentServiceImplWithoutDB studentService;
@Autowired
public StudentController(StudentServiceImplWithoutDB studentService) {
this.studentService = studentService;
}
@GetMapping
public List<StudentVO> getAll(){
List<StudentVO> studentVO= studentService.getAllStudents();
return studentVO;
}
}
Do Iнужно установить какой-либо путь или свойства для войны?Почти то же приложение работало как шарм со встроенным tomcat для простого Java-приложения