英文:
Spring framework 1.1.2 - Challenging...using the command line javac compiler with no Build Tools (Maven or Gradle..etc)
问题
目的:
我试图使用Spring框架1.1.2构建一个简单的Spring应用程序。这可以追溯到2004年。想法是从一堆类发展到引入注解以及大量减少开发人员工作量的方式,以便了解该框架的进展。我正在使用随Spring框架1.1.2分发的示例(Spring-MVC-step-by-step),该示例提供了当时Spring基于的JAR包。
问题:
问题是,如果您不使用构建工具自己创建所有的目录结构(src、war、WEB-INF),并将.java、.jsp文件放在适当的文件夹中,那么javac编译器在使用类路径环境变量查找与Spring相关的JAR包时会出现问题。我已经将所有相关的Spring JAR包放置在一个文件夹中,并相应地设置了CLASSPATH。然而,javac编译器会抛出以下错误:
SpringAppController.java:1: 错误: 包org.springframework.web.servlet.mvc不存在
SpringAppController.java:2: 错误: 包org.springframework.web.servlet不存在
SpringAppController.java:8: 错误: 找不到符号
import java.io.Exception;
无论您将JAR包放在何处,编译器都无法定位和使用它们。
是否有人知道如何在没有任何构建工具支持的情况下,使用javac和记事本编辑器构建一个简单的Spring应用程序?
即使在stackoverflow上进行了大量搜索,也没有找到关于这种尝试的任何结果。请给予建议。
英文:
Purpose :
I am trying to build a simple Spring Application using spring framework 1.1.2. This dates back to 2004. The idea was to understand how the framework progressed from being a bunch of classes to introducing Annotations and a plethora of ways reducing what the developer had to do. I am using the example
(Spring-MVC-step-by-step) distributed with the spring framework 1.1.2 dist, which provides the jars that spring was based on at that time.
Problem :
The problem is when you do not use a build tool and create all the directory structure yourself (src, war, WEB-INF) and place your .java , .jsp in the appropriate folders.. the javac compiler struggles to find the spring associated jars using the classpath env variable. I have all the associated spring jars placed into a folder and the CLASSPATH set accordingly..however the javac compiler throws the following errors
SpringAppController.java:1: error: package org.springframework.web.servlet.mvc does not exist
SpringAppController.java:2: error: package org.springframework.web.servlet does not exist
SpringAppController.java:8: error: cannot find symbol
import java.io.Exception;
No matter where you place the jars the compiler is unable to locate and use them.
Does anyone have an idea on how a simple Spring application can be built using the javac and a notepad editor without any support of any build tool ?
Even a ton of search on stackoverflow does not show any results on such an attempt. Please advice.
答案1
得分: 1
抱歉大家。。这真是愚蠢。。我只需要逐个将每个 Spring 框架的 .jar 文件单独添加到 CLASSPATH 中,这就足以让 javac 编译器找到适当的包。
英文:
Sorry folks.. This was stupid.. I just had to add each spring framework .jar file separately on the CLASSPATH and that was enough for the javac compiler to find the appropriate packages.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论