6
respostas

Erro com WebApplicationContext

Esta dando esse erro no eclipse WebApplicationContext cannot be resolved to a variable

e compilando esse erro Unresolved compilation problems: WebApplicationContext cannot be resolved to a variable Lambda expressions are allowed only at source level 1.8 or above Cannot refer to the non-final local variable model defined in an enclosing scope Cannot refer to the non-final local variable model defined in an enclosing scope

6 respostas

Tem 2 erros aí. O primeiro eh que parece que vc não declarou a variável... O segundo eh que seu projeto não ta configurado pra usar java8. Tenta usar o ctrl+1 do eclipse para resolver problemas de compilação.

Como eu declaro a variavel eu to revisando o curso eu me perdi nisso

Posta o trecho de código que tá dando erro, exatamente igual ao do eclipse.

Coloquei pra java 8 dei um build no projeto e um clean no servidor mas não funcionou ,não achei essa varialvel

Dez 31, 2016 6:19:28 PM org.apache.tomcat.util.digester.SetPropertiesRule begin ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:casadocodigo' did not find a matching property. Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Server version: Apache Tomcat/7.0.62 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Server built: May 7 2015 17:14:55 UTC Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Server number: 7.0.62.0 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: OS Name: Linux Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: OS Version: 3.13.0-24-generic Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Architecture: i386 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Java Home: /usr/lib/jvm/java-7-openjdk-i386/jre Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: JVM Version: 1.7.0_75-b13 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: JVM Vendor: Oracle Corporation Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: CATALINA_BASE: /home/thiago/curso java/apache-tomcat-7.0.62 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: CATALINA_HOME: /home/thiago/curso java/apache-tomcat-7.0.62 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Command line argument: -Dcatalina.base=/home/thiago/curso java/apache-tomcat-7.0.62 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Command line argument: -Dcatalina.home=/home/thiago/curso java/apache-tomcat-7.0.62 Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Command line argument: -Dwtp.deploy=/home/thiago/curso java/apache-tomcat-7.0.62/wtpwebapps Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=/home/thiago/curso java/apache-tomcat-7.0.62/endorsed Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.VersionLoggerListener log INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8 Dez 31, 2016 6:19:28 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386:/usr/lib/jvm/java-7-openjdk-i386/jre/../lib/i386:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/client:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386::/usr/java/packages/lib/i386:/usr/lib/i386-linux-gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib Dez 31, 2016 6:19:28 PM org.apache.coyote.AbstractProtocol init INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"] Dez 31, 2016 6:19:28 PM org.apache.coyote.AbstractProtocol init INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"] Dez 31, 2016 6:19:28 PM org.apache.catalina.startup.Catalina load INFORMAÇÕES: Initialization processed in 1007 ms Dez 31, 2016 6:19:28 PM org.apache.catalina.core.StandardService startInternal INFORMAÇÕES: Starting service Catalina Dez 31, 2016 6:19:28 PM org.apache.catalina.core.StandardEngine startInternal INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.62 Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.TldConfig execute INFORMAÇÕES: 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. Dez 31, 2016 6:19:31 PM org.apache.catalina.core.ApplicationContext log INFORMAÇÕES: No Spring WebApplicationInitializer types detected on classpath Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deploying web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/manager Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deployment of web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/manager has finished in 139 ms Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deploying web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/docs Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deployment of web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/docs has finished in 106 ms Dez 31, 2016 6:19:31 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deploying web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/examples Dez 31, 2016 6:19:32 PM org.apache.catalina.core.ApplicationContext log INFORMAÇÕES: ContextListener: contextInitialized() Dez 31, 2016 6:19:32 PM org.apache.catalina.core.ApplicationContext log INFORMAÇÕES: SessionListener: contextInitialized() Dez 31, 2016 6:19:32 PM org.apache.catalina.core.ApplicationContext log INFORMAÇÕES: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@7c233a') Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deployment of web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/examples has finished in 495 ms Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deploying web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/host-manager Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deployment of web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/host-manager has finished in 94 ms Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deploying web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/ROOT Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMAÇÕES: Deployment of web application directory /home/thiago/curso java/apache-tomcat-7.0.62/webapps/ROOT has finished in 65 ms Dez 31, 2016 6:19:32 PM org.apache.coyote.AbstractProtocol start INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"] Dez 31, 2016 6:19:32 PM org.apache.coyote.AbstractProtocol start INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"] Dez 31, 2016 6:19:32 PM org.apache.catalina.startup.Catalina start INFORMAÇÕES: Server startup in 3838 ms

@Controller @RequestMapping("/carrinho") @Scope(value=WebApplicationContext.SCOPE_SESSION, proxyMode=ScopedProxyMode.TARGET_CLASS) public class CarrinhoComprasController {

A anotação scope fica com subilinhado vermelho em WebApplicationContext e quando coloco o ponteiro do mouse em cima me mostra a seguinte informação WebApplicationContext cannot be resolved to a variable

Isso ocorre em todas as classes que tem essa anotação para scope