您好我根据以下教程创建了我的Maven项目:http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
我遇到问题在Java Build Path中找不到超类“javax.servlet.http.HttpServlet”,我通过这种方式修复它 http://i.stack.imgur.com/3KBnz.png 但页面没有打开(请求的资源不可用。)
控制台的输出:
:\Plip 17, 2015 10:56:05 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Testmaven' did not find a matching property.
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.24
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jul 1 2015 20:19:55 UTC
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.24.0
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: Crogram Files\Java\jre1.8.0_31
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_31-b13
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\Damian\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Program Files (x86)\apache-tomcat-8.0.24
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\Damian\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files (x86)\apache-tomcat-8.0.24
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\Damian\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files (x86)\apache-tomcat-8.0.24\endorsed
lip 17, 2015 10:56:05 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1250
lip 17, 2015 10:56:05 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_45/bin/server;C:/Program Files/Java/jre1.8.0_45/bin;C:/Program Files/Java/jre1.8.0_45/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\PROGRA~2\Borland\CBUILD~1\Bin;C:\PROGRA~2\Borland\CBUILD~1\Projects\Bpl;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.8.0_31\bin;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\apache-maven-3.3.3\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\Damian\Desktop\eclipse;;.
lip 17, 2015 10:56:06 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
lip 17, 2015 10:56:06 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
lip 17, 2015 10:56:06 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
lip 17, 2015 10:56:06 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
lip 17, 2015 10:56:06 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1099 ms
lip 17, 2015 10:56:06 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
lip 17, 2015 10:56:06 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.24
lip 17, 2015 10:56:06 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [388] milliseconds.
lip 17, 2015 10:56:09 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
lip 17, 2015 10:56:09 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
10:56:09,216 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
10:56:09,217 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
10:56:09,218 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Users/Damian/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Testmaven/WEB-INF/classes/logback.xml]
10:56:09,341 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
10:56:09,352 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
10:56:09,377 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
10:56:09,560 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
10:56:09,560 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
10:56:09,560 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
10:56:09,562 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.dgrzankowski.controller] to DEBUG
10:56:09,562 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.dgrzankowski.controller] to false
10:56:09,562 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.dgrzankowski.controller]
10:56:09,564 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
10:56:09,564 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
10:56:09,564 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
10:56:09,566 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@708815e2 - Registering current configuration as safe fallback point
lip 17, 2015 10:56:09 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
lip 17, 2015 10:56:10 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'mvc-dispatcher'
lip 17, 2015 10:56:11 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
lip 17, 2015 10:56:11 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
lip 17, 2015 10:56:11 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5167 ms
知道出了什么问题吗?
答案 0 :(得分:0)
在void button_press(object B)
{
m=list of buttons
for i running from 0:m
if (i=B)
i.FrontWeight=FrontWeights.Bold;
else
i.FrontWeight=FrontWeights.Light;
}
pom.xml
或
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
并尝试<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
和clean install
项目
答案 1 :(得分:0)
由于Servlet jar
没有进入类路径而发生此问题,因此您需要通过以下步骤将servlet
jar添加到类路径中。
Right click
- &gt;属性&gt;目标运行时 - &gt;选择服务器,如果服务器不存在,则创建新服务器,然后从Target Runtimes
或者您可以像这样添加pom.xml
依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>