IntelliJ Spring MVC @RequestMapping Not Registering
Posted: December 27, 2017 | Author: ThomasPowell | Filed under: java | Tags: requestMapping, spring | Comments Off on IntelliJ Spring MVC @RequestMapping Not RegisteringI’ve been trying to reintroduce myself to Spring MVC @RequestMapping and working with Java in IntelliJ after 5 years away from Java and having primarily used Netbeans for any development. My last experience with Java was with Netbeans helping manage a Maven build.
I had my @RequestMapping
annotations set up, and IntelliJ is launching Tomcat directly (vs. deploying to an already running instance). I created my *-servlet.xml
configurations, and had my .jsp
files placed properly. Everything seemed to be in good shape and compiling fine, but the routes I specified we not showing up with the project was run.
Eventually, I went to Build -> Build Artifacts -> …:war:exploded -> Edit… and went the Project Settings -> Artifacts tab and noticed “Library ‘org.springframework:spring-web:4.3.13-RELEASE’ required for module ‘…’ is missing from the artifact”. Upon clicking “Fix” and adding the dependency. Some combination of that dependency and ‘org.springframework:spring-webmvc:4.3.13-RELEASE’ missing prevented the org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler
from processing my @RequestMapping
annotations.
Multiple Postgres Schemas and Rails db:test:prepare
Posted: December 22, 2017 | Author: ThomasPowell | Filed under: Uncategorized | Tags: rails, schema, tests | Comments Off on Multiple Postgres Schemas and Rails db:test:prepareIn our Rails databases, we use multiple Postgres schemas. This is partly for partitioning archive data from fresh data. On a new Rails 5 project, I started having tests fail once the models had the “archivable” concern added, which depended on an archive schema existing.
Ultimately, the problem is that the archive schema wasn’t being created in the test database, because rake db:test:prepare
performs a db:test:load
which was loading the db/schema.rb
, which is completely ignorant of the Postgres-specific schema concept.
In order to fix this without attempting ugly hacks, the simplest solution was just to switch to using structure.sql
for the Rails schema dump.
In config/application.rb
, insert the following in your Application
class definition:
config.active_record.schema_format = :sql
If you haven’t already added the additional schema(s) to your schema_search_path
in your config/database.yml
.
database: whatever_db
schema_search_path: 'main,main_archive,public'
You’ll need to run rake db:migrate
to force structure.sql
generation before running tests again. Also, be sure to switch from schema.rb
to structure.sql
if you’re committing this file.
Postgres 9.4 via Homebrew on macOS
Posted: December 7, 2017 | Author: ThomasPowell | Filed under: Uncategorized | Comments Off on Postgres 9.4 via Homebrew on macOSI needed to run an old version of Postgres in order to be supported by the version of Rails I was working with, and I had a new Mac with High Sierra installed. Found out after a bit of “Why doesn’t this postgres formula link its executables?” that it was precisely because of the age of the version that it wasn’t linking. (In my old Linux days I would have just automatically added the PATH or made the link, but I also would have probably rebuilt the Linux install within a few months, anyway.)
# doh this is a keg-only formula. Had to manually link CLI regardless of install method | |
# run these to set up | |
brew tap homebrew/versions | |
brew install homebrew/versions/postgres94 | |
brew services start postgresql@9.4 export | |
# in your shell's RC file: | |
PATH=/usr/local/opt/postgresql@9.4/bin:$PATH | |
LDFLAGS=-L/usr/local/opt/postgresql@9.4/lib | |
CPPFLAGS=-I/usr/local/opt/postgresql@9.4/include | |
# For pkg-config to find this software you may need to set: | |
PKG_CONFIG_PATH=/usr/local/opt/postgresql@9.4/lib/pkgconfig | |
# -= end shell RC file =- | |
# do your normal postgresql setup now | |
initdb | |
psql |